Skip to content

Instantly share code, notes, and snippets.

@resting
Created June 3, 2012 06:07
Show Gist options
  • Save resting/2862183 to your computer and use it in GitHub Desktop.
Save resting/2862183 to your computer and use it in GitHub Desktop.
backup mysql script
# replace [] with your own config
# replace own dir to save
# echo doesn't work. hmm...
mysql -u[uname] -p'[pwd]' -e "show databases" \
| grep -Ev 'Database|information_schema' \
| while read dbname; \
do \
echo 'Dumping $dbname' \
mysqldump -u[uanme] -p'[pwd]' $dbname > ~/db_backup/$dbname.sql;\
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment