Created
May 24, 2022 09:07
-
-
Save noweh/b965f2ac439ec7a7d75ac40ab1dc2c89 to your computer and use it in GitHub Desktop.
mysqldump skip content from some tables (for GDRP)
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 | |
HOST_NAME=XXXX | |
USER=XXXX | |
PASSWORD=XXXX | |
DATABASE_NAME=XXXX | |
DB_FILE=export.sql | |
EXCLUDED_TABLES=( | |
table1 | |
table2 | |
table3 | |
table4 | |
) | |
IGNORED_TABLES_STRING='' | |
for TABLE in "${EXCLUDED_TABLES[@]}" | |
do | |
IGNORED_TABLES_STRING+=" --ignore-table=${DATABASE_NAME}.${TABLE}" | |
done | |
echo "Dump structure" | |
mysqldump --host=${HOST_NAME} --user=${USER} --password=${PASSWORD} --single-transaction --no-data --routines ${DATABASE_NAME} > ${DB_FILE} | |
echo "Dump content" | |
mysqldump --host=${HOST_NAME} --user=${USER} --password=${PASSWORD} ${DATABASE_NAME} --no-create-info --skip-triggers ${IGNORED_TABLES_STRING} >> ${DB_FILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment