Created
October 20, 2009 09:43
-
-
Save msadouni/214132 to your computer and use it in GitHub Desktop.
Backup all dbs in separate files
This file contains hidden or 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/sh | |
# Backup all dbs in separate files | |
# adapted from | |
# http://www.usercore.com/backup-all-mysql-databases-as-seperate-sql-files/ | |
# use mysqldump5 for MacPorts, mysqldump otherwise | |
user='user' | |
password='password' | |
to='/path/to/backup/folder' # without final / | |
for db in `mysql -u${user} -p${password} -e "show databases" -B -N` | |
do | |
echo "Dumping $db" | |
mysqldump5 -u${user} -p${password} $db | gzip > ${to}/${db}.sql.gz | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment