Created
July 5, 2011 16:31
-
-
Save carlosromero/1065197 to your computer and use it in GitHub Desktop.
Mysql dump by tables
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 | |
USER=root | |
PASS= | |
DBNAME=mydb | |
DIRLOCAL=/home/user/dumps/ | |
cd $DIRLOCAL | |
mkdir `date +%Y%m%d` | |
cd `date +%Y%m%d` | |
for table in `echo "show tables" | mysql -u $USER -p$PASS $DBNAME | grep -v ^mysql$ | grep -v ^Tables_in_$DBNAME$`; | |
do | |
#one file per table | |
mysqldump --add-drop-table --routines -u $USER -p$PASS $DBNAME ${table}> ${table}.sql; | |
done | |
gzip * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment