jfreak53

mysqldump with Wildcard

Nov 30th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.28 KB | None | 0 0
  1. #!/bin/bash
  2. if [ $# -lt 2 ]
  3. then
  4.         echo "Usage: `basename $0` database wildcardpattern"
  5.         echo "Eg: `basename $0` mydatabase App_%"
  6.         exit 1
  7. fi
  8. database=$1
  9. pattern=$2
  10. mysqldump $database `mysql -ND $database -e "SHOW TABLES LIKE '$pattern'" | awk '{printf $1" "}'`
Add Comment
Please, Sign In to add comment