This commit is contained in:
olli 2024-08-06 11:55:29 +02:00
parent d07f953730
commit 83c4c651d3

View File

@ -205,13 +205,18 @@
. /home/docker/_defaults/mariadb/envroot.db
DAYS=7
TIMESTAMP=$(date +"%Y%m%d%H%M")
mariadb-dump -u root -h mariadb.{{inventory_hostname}} --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} --all-databases >${g_tmp}/dberr | gzip > $BACKUPDIR/MARIADB-$TIMESTAMP.sql.gz || g_echo_error "MariaDB Backup failed $(cat ${g_tmp}/dberr)"
unset MARIADB_ROOT_PASSWORD
# dont delete last old backups!
OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz | wc -l)
if [ $OLD_BACKUPS -gt $DAYS ]; then
find $BACKUPDIR -name "$i*.gz" -daystart -mtime +$DAYS -delete
fi
for i in $(echo "show databases" | mariadb -u root -h mariadb.{{inventory_hostname}} --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} | grep -v "^Database$")
do
mariadb-dump -u root -h mariadb.$(hostname) --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} $i >${g_tmp}/dberr | gzip > $BACKUPDIR/MARIADB-$i-$TIMESTAMP.sql.gz || g_echo_error "MariaDB Backup failed $(cat ${g_tmp}/dberr)"
unset MARIADB_ROOT_PASSWORD
# dont delete last old backups!
OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz | wc -l)
if [ $OLD_BACKUPS -gt $DAYS ]
then
find $BACKUPDIR -name "MARIADB-$i*.gz" -daystart -mtime +$DAYS -delete
fi
done
backup: yes
validate: /bin/bash -n %s