fixed deletion of yesterdays dump
This commit is contained in:
parent
70e2552ded
commit
aff303746e
5
backupdb
5
backupdb
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
OUTPUT="/var/lib/backupdb"
|
OUTPUT="/var/lib/backupdb"
|
||||||
|
|
||||||
cd $OUTPUT
|
cd $OUTPUT
|
||||||
|
@ -8,9 +10,10 @@ databases=`mysql -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
|
||||||
|
|
||||||
for db in $databases; do
|
for db in $databases; do
|
||||||
if [[ "$db" != "information_schema" ]] && [[ "$db" != "performance_schema" ]] && [[ "$db" != _* ]]; then
|
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
|
DUMP=$OUTPUT/`date +%Y%m%d`.$db.sql
|
||||||
echo "Dumping database: $db"
|
echo "Dumping database: $db"
|
||||||
if [[ -f ${DUMP}.gz ]]; then rm ${DUMP}.gz; fi
|
|
||||||
mysqldump --databases $db > $DUMP
|
mysqldump --databases $db > $DUMP
|
||||||
gzip $DUMP
|
gzip $DUMP
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue