Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 21st, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. if [ "$1" == "" ]; then
  4.     echo "Usage: $0  [output-path]"
  5.     exit 1
  6. fi
  7.  
  8. TABLES=`mysql -B -N -e "select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA='$1'"`
  9.  
  10. OUT="$2"
  11. if [ "$OUT" == "" ]; then
  12.     OUT="."
  13. fi
  14. if [ ! -d $OUT ]; then
  15.     echo "$OUT does not exist"
  16.     exit 1
  17. fi
  18.  
  19. for table in $TABLES; do
  20.     echo -n "dumping $1.$table..."
  21.     mysqldump $1 $table > $OUT/$1.$table.sql
  22.     echo "done"
  23. done