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