From 92295ba7ab0a1d6210fd2a122fef7ee88cab7265 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 8 Jul 2020 17:56:15 +0200 Subject: [PATCH] Optionally add password --- templates/postgresql-backup-script.sh | 3 +++ vars/main.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/postgresql-backup-script.sh b/templates/postgresql-backup-script.sh index 326fdc5..cf51a67 100644 --- a/templates/postgresql-backup-script.sh +++ b/templates/postgresql-backup-script.sh @@ -15,6 +15,9 @@ create_backup_dir() { backup_databases() { {% for db in postgresql_backup.databases %} + {% if db.password -%} + export PGPASSWORD="{{ db.password }}" + {% endif %} if (umask 077 && pg_dump -F c -h "{{ db.host | default( 'localhost' ) }}" -U "{{ db.user | default( 'postgres' ) }}" -p "{{ db.port | default( '5432' ) }}" "{{ db.name }}" -f "{{ db.name }}.in_progress.psql"); then mv "{{ db.name }}.in_progress.psql" "{{ db.name }}.psql" else diff --git a/vars/main.yml b/vars/main.yml index db42e90..f5f1060 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,6 @@ --- # versionscheck -playbook_version_number: 15 # should be int +playbook_version_number: 16 # should be int playbook_version_path: 'role-postgresql-backup_roles-ansible_github.com.version' # unique string _postgresql_backup: