Fix for Shell script for taking a copy of a remote database to your local machine.

  1. if [ $1 = "--help" ];
  2.   then
  3.     echo "
  4.   #########
  5.   # USAGE #
  6.   #########
  7.  
  8.   Syntax for running this script is:
  9.     ./devdb2localdb.sh sshuser sshdomain remotedatabaseuser databasename
  10.    
  11.     sshuser -             string, username for ssh connection
  12.     sshdomain -           string, the actual domain where the remote database is
  13.     remotedatabaseuser -  string, username for remote database
  14.     databasename -        string, name of database
  15.     ." &  
  16.   else
  17.     echo "Getting remote db called $4 from $1@$2 ..."
  18.     ssh $1@$2 "mysqldump -u $3 $4 | bzip2" |  bzip2 -d > dump.sql
  19.     echo "Resetting local db called $4 ..."
  20.     echo "drop database $4;" | mysql -u $3
  21.     echo "create database $4;" | mysql -u $3
  22.     echo "Logging in and restoring db dump to $4 ..."
  23.     mysql -u root -h 127.0.0.1 $4  < dump.sql
  24.     echo "Deleting db dump ..."
  25.     rm dump.sql
  26.     echo "Done!"
  27. fi

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.