Skip to content

Instantly share code, notes, and snippets.

@fedir
Created May 29, 2013 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedir/5669116 to your computer and use it in GitHub Desktop.
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
#!/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