Skip to content

Instantly share code, notes, and snippets.

@sergeycherepanov
Last active September 21, 2018 19:56
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 sergeycherepanov/ed72a443b3182d238532834383a50f00 to your computer and use it in GitHub Desktop.
Save sergeycherepanov/ed72a443b3182d238532834383a50f00 to your computer and use it in GitHub Desktop.
akeneo_fastdump.sh
#!/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 'pim_versioning_version';" ${dbname} >> /tmp/${dbname}_tables.txt
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'pim_notification%';" ${dbname} >> /tmp/${dbname}_tables.txt
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'akeneo_batch_job_execution%';" ${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