ansible/roles/mariadb_server/files/backup-database
Kevin Fenzi 0e815134b7 mariadb: use pxz with 2 threads for backups
This has anoyingly been alerting of late, so lets try and
see if we can get the backup to finish faster and avoid the
alerts on it.

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
2025-01-20 12:49:47 -08:00

13 lines
404 B
Bash

#!/bin/bash
# Backup a database *locally* to /backups/.
DB=$1
# Make our latest backup
ionice -c3 /bin/mysqldump --user=root --add-drop-database $DB | /usr/bin/pxz -T2 > /backups/$DB-$(date +%F).dump.xz
# link to the latest backup
ln -sf /backups/$DB-$(date +%F).dump.xz /backups/$DB-latest.xz
# Also, delete the backup from a few days ago.
rm -f /backups/$DB-$(date --date="3 days ago" +%F).dump.xz