Created
February 24, 2017 21:57
-
-
Save marcomontalbano/48eaa96b546b2a0aa6901c7cabe7e457 to your computer and use it in GitHub Desktop.
Ignore tables using MySQL Dump
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
# usage: ./dump.sh | |
HOST=127.0.0.1 | |
USER=root | |
DATABASE=database | |
OUTPUT=dump.sql.zip | |
EXCLUDED_TABLES=( | |
table1 | |
table2 | |
tableN | |
) | |
IGNORED_TABLES_STRING="" | |
for TABLE in "${EXCLUDED_TABLES[@]}" | |
do : | |
IGNORED_TABLES_STRING+=" --ignore-table=${DATABASE}.${TABLE}" | |
done | |
mysqldump -v --host=$HOST --user=$USER --single-transaction --no-data $DATABASE 2> dump.log | gzip > $OUTPUT | |
mysqldump -v --host=$HOST --user=$USER $DATABASE --no-create-info $IGNORED_TABLES_STRING 2> dump.log | gzip >> $OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment