Skip to content

Instantly share code, notes, and snippets.

@marcomontalbano
Created February 24, 2017 21:57
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 marcomontalbano/48eaa96b546b2a0aa6901c7cabe7e457 to your computer and use it in GitHub Desktop.
Save marcomontalbano/48eaa96b546b2a0aa6901c7cabe7e457 to your computer and use it in GitHub Desktop.
Ignore tables using MySQL Dump
# 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