diff --git a/postgresql/files/postgresql-backup.cron b/postgresql/files/postgresql-backup.cron index 91fa4c82..87339f19 100755 --- a/postgresql/files/postgresql-backup.cron +++ b/postgresql/files/postgresql-backup.cron @@ -40,7 +40,9 @@ if [ $PG_BACKUP_ENABLED == 'True' ] ; then if [ ! -d $LOG_DIR ] ; then mkdir -p $LOG_DIR fi - $PG_BCK_BIN > $LOG_FILE 2>&1 + echo "Starting the backup procedure" > $LOG_FILE + $PG_BCK_BIN >> $LOG_FILE 2>&1 + echo "Backup procedure finished" >> $LOG_FILE fi else echo "Postgresql backups administratively disabled" > $LOG_FILE diff --git a/postgresql/tasks/postgresql-backup.yml b/postgresql/tasks/postgresql-backup.yml index 4e3dd813..9210352b 100644 --- a/postgresql/tasks/postgresql-backup.yml +++ b/postgresql/tasks/postgresql-backup.yml @@ -23,3 +23,6 @@ when: psql_wal_files_archiving_enabled tags: [ 'pg_backup', 'postgresql', 'postgres' ] +- name: authorization file for the psql command + template: src=pgpass.j2 dest={{ pg_backup_pass_file }} owner=root mode=0600 + tags: [ 'pg_backup', 'postgresql', 'postgres', 'pgpass' ] diff --git a/postgresql/tasks/postgresql-config.yml b/postgresql/tasks/postgresql-config.yml index 35b6c108..b16ad51c 100644 --- a/postgresql/tasks/postgresql-config.yml +++ b/postgresql/tasks/postgresql-config.yml @@ -17,6 +17,3 @@ notify: Restart postgresql tags: [ 'postgresql', 'postgres', 'pg_conf' ] -- name: authorization file for the psql command - template: src=pgpass.j2 dest={{ pg_backup_pass_file }} owner=root mode=0600 - tags: [ 'pg_backup', 'postgresql', 'postgres' ] diff --git a/postgresql/templates/pgpass.j2 b/postgresql/templates/pgpass.j2 index 1586807a..c3d7f75e 100644 --- a/postgresql/templates/pgpass.j2 +++ b/postgresql/templates/pgpass.j2 @@ -1,8 +1,10 @@ # Loop psql_db_data to add multiple databases {% if psql_db_data is defined %} {% for db in psql_db_data %} -{%if db.pwd is defined %} +{% if db.pwd is defined %} +{% if db.managedb is defined and db.managedb %} {{ psql_db_host }}:{{ psql_db_port }}:{{ db.name }}:{{ db.user }}:{{ db.pwd }} {% endif %} +{% endif %} {% endfor %} {% endif %}