From aff303746e315871027b39d11a08c495fa334c11 Mon Sep 17 00:00:00 2001 From: tracer Date: Thu, 2 Jan 2020 16:47:15 +0100 Subject: [PATCH] fixed deletion of yesterdays dump --- backupdb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backupdb b/backupdb index 009b14a..8b97dd1 100755 --- a/backupdb +++ b/backupdb @@ -1,5 +1,7 @@ #!/bin/bash +set -x + OUTPUT="/var/lib/backupdb" cd $OUTPUT @@ -8,9 +10,10 @@ databases=`mysql -e "SHOW DATABASES;" | tr -d "| " | grep -v Database` for db in $databases; do if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != _* ]]; then + YESTERDAY=$OUTPUT/`date --date='yesterday' +%Y%m%d`.$db.sql.gz + if [[ -f ${YESTERDAY} ]]; then rm ${YESTERDAY}; fi DUMP=$OUTPUT/`date +%Y%m%d`.$db.sql echo "Dumping database: $db" - if [[ -f ${DUMP}.gz ]]; then rm ${DUMP}.gz; fi mysqldump --databases $db > $DUMP gzip $DUMP fi