fixed deletion of yesterdays dump

This commit is contained in:
tracer 2020-01-02 16:47:15 +01:00
parent 70e2552ded
commit aff303746e
1 changed files with 4 additions and 1 deletions

View File

@ -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