1
0
Fork 0
mirror of https://gitlab.com/s3lph/ansible-collection-dirvish synced 2024-11-10 03:16:22 +01:00
ansible-collection-dirvish/docs/templates/mysql-snapshot.sh.j2
2020-10-31 05:23:51 +01:00

21 lines
624 B
Django/Jinja

#!/bin/bash
{{ ansible_managed | comment }}
#
# THIS IS AN EXAMPLE
# If you want to use this, adapt to your needs and remove the "exit 1"
#
exit 1
set -e
BACKUPDIR={{ dirvish_client_mysql_backupdir | quote }}
MYSQL_BACKUP_CONFIG=/root/.my.cnf
DATABASES=$(mysql --defaults-extra-file=${MYSQL_BACKUP_CONFIG} --skip-column-names --batch --execute 'SHOW DATABASES')
for DB in $DATABASES; do
if [[ "$DB" == "mysql" || "$DB" == "information_schema" || "$DB" == "performance_schema" ]]; then
continue
fi
mysqldump --defaults-extra-file=${MYSQL_BACKUP_CONFIG} --databases "${DB}" | xz > "${BACKUPDIR}/${DB}.xz"
done