ansible/roles/postgresql_server/files/backup-database.db-datanommer02
Kevin Fenzi abee63c966 postgresql_server: adjust backups for db-datanommer02
Currently backups are taking 17-18 hours with 4 threads.
Now that we have 16 cpus defined there, lets bump that up to 8 and see
if that lowers things much. If not we can look at moving to another
compression, but the database is very large so lots of compression is
good to save disk space.

Also filter out another output of the backup job that causes cron
emails.

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
2024-05-20 10:28:04 -07:00

16 lines
529 B
Bash

#!/bin/bash
# Backup a database *locally* to /backups/.
# Sleep a bit so we do not have a thundering herd on db hosts
sleep $[ ( $RANDOM % 7200 ) + 1 ]s
DB=$1
# Make our latest backup
# Make it use a limited number of threads because pxz will use all the
# cpus which causes pg_dump to starve which causes...
/usr/bin/pg_dump --exclude-table-data=sessions -C $DB | /usr/bin/pxz -T8 > /backups/$DB-$(date +%F).dump.xz
# Also, delete the backup from a few days ago.
rm -f /backups/$DB-$(date --date="1 days ago" +%F).dump.xz