Created
August 5, 2013 17:49
-
-
Save crazyrohila/6157902 to your computer and use it in GitHub Desktop.
This is shell script to take backup from server and update db to local system.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
#This is very simple script. All commands will run one by one. So If any command will fail, Script will not stop. | |
#You Should have install drush on server and provide ssh password. | |
ssh <USER>@<SERVER> "drush -r <DRUPAL_ROOT_DIR> sql-dump|bzip2 -c" > db.sql.bz2 | |
echo 'db dump from server'; | |
bunzip2 db.sql.bz2 | |
echo 'unziped db'; | |
#Delete the old db replace <password> with original password (without any space after -p). | |
mysqladmin -f -u <mysql-user> -p<password> drop <DB_NAME> | |
#Now Create New db with same name and import dumped sql file in it. | |
mysqladmin -u <mysql-user> -p<password> create <DB_NAME> && mysql -u <mysql-user> -p<password> <DB_NAME> < db.sql | |
echo 'db imported in <DB_NAME> database'; | |
#I Don't want this file now, So delete it. If you want to keep then comment below lines. | |
rm db.sql | |
echo 'db updated and sql file removed'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment