Created
June 22, 2009 18:59
-
-
Save ryanschwartz/134124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
########################################################### | |
# Back up MySQL databases | |
########################################################### | |
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | |
BACKUP_DIR="." | |
# Do not backup these databases | |
IGNORE="test" | |
# Get list of all databases | |
DB_LIST=`mysql -Bse 'show databases'` | |
for db in $DB_LIST; do | |
# set skip variable | |
skip=0 | |
if [ "$IGNORE" != "" ]; then | |
for i in $IGNORE; do | |
[ "$db" == "$i" ] && skip=1 || : | |
done | |
fi | |
if [ "$skip" == "0" ]; then | |
mysqldump $db | gzip -9 > $BACKUP_DIR/$db.sql.gz | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment