Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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 'sales\_%';" ${dbname} >> /tmp/${dbname}_tables.txt
- mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'log\_%';" ${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}\""
Add Comment
Please, Sign In to add comment