Last active
August 3, 2018 19:53
-
-
Save sergeycherepanov/08cdc8d6cac32904834d137955dfd22d to your computer and use it in GitHub Desktop.
Dumping the magento 2 database without data of heavy tables
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=$1 | |
user=$2 | |
password=$3 | |
dbname=$4 | |
[[ -f /tmp/${dbname}_tables.txt ]] && rm /tmp/${dbname}_tables.txt | |
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'ewave_ai_logs%';" ${dbname} >> /tmp/${dbname}_tables.txt | |
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'sales\_%';" ${dbname} >> /tmp/${dbname}_tables.txt | |
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'quote%';" ${dbname} >> /tmp/${dbname}_tables.txt | |
mysqldump --no-data --skip-lock-tables "-h${host}" -u${user} -p${password} ${dbname} | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | |
echo "" | |
bash -c "mysqldump $(cat /tmp/${dbname}_tables.txt | xargs -I{} printf '--ignore-table '${dbname}'.{} ') --insert-ignore --skip-triggers --no-create-info --skip-lock-tables \"-h${host}\" \"-u${user}\" \"-p${password}\" \"${dbname}\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment