ansible/roles/mariadb_server/files/backup-database
Kevin Fenzi 140af2c7ac This has to have a --user=root in order to be able to access the dbs
It runs as mysql user, but root when connecting to the db.
2015-06-04 18:37:12 +00:00

10 lines
296 B
Bash

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