Created
May 29, 2013 09:31
-
-
Save fedir/5669116 to your computer and use it in GitHub Desktop.
Dumps all tables except some #MySQL #DBA // via http://dba.stackexchange.com/a/9309/9104
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 | |
# Define constants | |
DBTODUMP=mydb | |
MYUSER=mydb | |
MYPASSWORD=mydb | |
MYTABLESEXCEPT="'t1','t2','t3'" | |
MYDBPATH=mydb_tables.sql | |
MYACL="-u${MYUSER} -p${MYPASSWORD}" | |
# Get table list | |
TBLIST=`mysql $MYACL -AN -e"select group_concat(table_name separator ' ') from information_schema.tables where table_schema='${DBTODUMP}' and table_name not in ('t1','t2','t3')"` | |
# Dump the tables | |
mysqldump $MYACL ${DBTODUMP} ${TBLIST} > $MYDBPATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment