backup-fix

This commit is contained in:
olli 2024-08-20 14:37:12 +02:00
parent c3ef02e97f
commit 15939f86b4

View File

@ -208,9 +208,14 @@
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.{{inventory_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)"
if mariadb-dump -u root -h mariadb.{{inventory_hostname}} --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} $i 2>${g_tmp}/dberr >$BACKUPDIR/MARIADB-$i-$TIMESTAMP.sql
then
gzip $BACKUPDIR/MARIADB-$i-$TIMESTAMP.sql
else
g_echo_error "MariaDB Backup failed $(cat ${g_tmp}/dberr)"
fi
# dont delete last old backups!
OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz | wc -l)
OLD_BACKUPS=$(ls -1 $BACKUPDIR/MARIADB-$i*.gz | wc -l)
if [ $OLD_BACKUPS -gt $DAYS ]
then
find $BACKUPDIR -name "MARIADB-$i*.gz" -daystart -mtime +$DAYS -delete