19 lines
501 B
Bash
Executable File
19 lines
501 B
Bash
Executable File
#!/bin/bash
|
|
|
|
OUTPUT="/var/lib/backupdb"
|
|
|
|
cd $OUTPUT
|
|
|
|
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"
|
|
mysqldump --databases $db > $DUMP
|
|
gzip $DUMP
|
|
fi
|
|
done
|