From e6037d4f3d4fc1185186f6f185a12d8f3d01cf48 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 7 Jul 2021 09:00:04 +0200 Subject: [PATCH] Update to 2021-07-07 09:00 --- roles/mysql_server/templates/pre-backup.j2 | 3 +++ roles/postgresql_server/templates/pre-backup.sh.j2 | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/roles/mysql_server/templates/pre-backup.j2 b/roles/mysql_server/templates/pre-backup.j2 index d261305..4368235 100644 --- a/roles/mysql_server/templates/pre-backup.j2 +++ b/roles/mysql_server/templates/pre-backup.j2 @@ -14,6 +14,7 @@ do {% for db in mysql_skip_backup %} # {{ db }} is configured not to be backed up if [[ "$DB" == "{{ db }}" ]]; then + echo "Skiping $DB as per configuration" continue fi {% endfor %} @@ -33,8 +34,10 @@ do {% else %} {% set compext = 'z' %} {% endif %} + echo "Dumping $DB to $DEST/$DB.sql.{{ compext }}" /usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table $DB | /bin/nice -n 10 {{ mysql_compress_cmd }} > $DEST/$DB.sql.{{ compext }} {% else %} + echo "Dumping $DB to $DEST/$DB.sql" /usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table $DB -r $DEST/$DB.sql {% endif %} done diff --git a/roles/postgresql_server/templates/pre-backup.sh.j2 b/roles/postgresql_server/templates/pre-backup.sh.j2 index f6963f1..b56b3e8 100644 --- a/roles/postgresql_server/templates/pre-backup.sh.j2 +++ b/roles/postgresql_server/templates/pre-backup.sh.j2 @@ -31,20 +31,29 @@ do {% else %} {% set comp_ext = 'z' %} {% endif %} + echo "Dumping $DB to $DEST/$DB.{{ dump_ext }}.{{ comp_ext }}" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dump {{ dump_options }} $DB" | /bin/nice -n 10 {{ pg_compress_cmd }} > $DEST/$DB.{{ dump_ext }}.{{ comp_ext }} + echo "Dumping $DB schema to $DEST/$DB.schema.{{ dump_ext }}.{{ comp_ext }}" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dump --schema-only -Fp $DB" | /bin/nice -n 10 {{ pg_compress_cmd }} > $DEST/$DB.schema.{{ dump_ext }}.{{ comp_ext }} {% else %} + echo "Dumping $DB to $DEST/$DB.{{ dump_ext }}" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dump {{ dump_options }} $DB" > $DEST/$DB.{{ dump_ext }} + echo "Dumping $DB schema to $DEST/$DB.schema.sql" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dump --schema-only -Fp $DB" > $DEST/$DB.schema.sql {% endif %} done {% if pg_compress_cmd %} +echo "Dumping globals to $DEST/pg_globals.sql.{{ comp_ext }}" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dumpall --globals-only" | /bin/nice -n 10 {{ pg_compress_cmd }} > $DEST/pg_globals.sql.{{ comp_ext }} +echo "Dumping all schemas to $DEST/pg_schema.sql.{{ comp_ext }}" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dumpall --schema-only" | /bin/nice -n 10 {{ pg_compress_cmd }} > $DEST/pg_schema.sql.{{ comp_ext }} {% else %} +echo "Dumping globals to $DEST/pg_globals.sql" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dumpall --globals-only" > $DEST/pg_globals.sql +echo "Dumping all schemas to $DEST/pg_schema.sql" su - postgres -c "{{ (pg_version != 'default') | ternary('/usr/pgsql-' + pg_version | string,'') }}/bin/pg_dumpall --schema-only" > $DEST/pg_schema.sql {% endif %} +echo "Dumping config to $DEST" cp -a /var/lib/pgsql/{{ (pg_version != 'default') | ternary(pg_version | string + '/','') }}data/postgresql.conf $DEST/ cp -a /var/lib/pgsql/{{ (pg_version != 'default') | ternary(pg_version | string + '/','') }}data/pg_hba.conf $DEST/