Guest User

Untitled

a guest
Jan 3rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. host=$1
  4. user=$2
  5. password=$3
  6. dbname=$4
  7.  
  8. [[ -f /tmp/${dbname}_tables.txt ]] && rm /tmp/${dbname}_tables.txt
  9.  
  10. mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'sales\_%';" ${dbname} >> /tmp/${dbname}_tables.txt
  11. mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'log\_%';" ${dbname} >> /tmp/${dbname}_tables.txt
  12.  
  13. mysqldump --no-data --skip-lock-tables "-h${host}" -u${user} -p${password} ${dbname} | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/'
  14.  
  15. echo ""
  16.  
  17. 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