ansible/roles/mariadb_server/files/backup-database
Kevin Fenzi f136cfec2a mariadb: set single-transaction on backups
We are seeing the backups here cause the wiki to become unresponsive.
This might help it out and prevent it locking things while doing the
backups.

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
2025-06-01 08:02:12 -07:00

13 lines
425 B
Bash

#!/bin/bash
# Backup a database *locally* to /backups/.
DB=$1
# Make our latest backup
ionice -c3 /bin/mysqldump --single-transaction --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