Created
March 20, 2012 10:23
-
-
Save bohman/2133890 to your computer and use it in GitHub Desktop.
Database dump script
This file contains 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
#!/usr/bin/env bash | |
# Remote database credentials | |
RDBNAME="" | |
RDBUSER="" | |
RDBPASS="" | |
# Local database credentials | |
LDBNAME="" | |
LDBUSER="" | |
LDBPASS="" | |
# SSH credentials | |
SSHUSER="" | |
SSHADRESS="" | |
# Script: | |
# 1. Dump DB | |
# 2. Copy dump to local | |
# 3. Remove dump from remote | |
# 4. Import dump into local | |
echo "mysqldump -u$RDBUSER -p$RDBPASS $RDBNAME > ~/$RDBNAME.sql" | ssh $SSHUSER@$SSHADRESS | |
scp $SSHUSER@$SSHADRESS:~/$RDBNAME.sql ./ | |
echo "rm ~/$RDBNAME.sql" | ssh $SSHUSER@$SSHADRESS | |
cat $RDBNAME.sql | mysql -hlocalhost -u$LDBUSER -p$LDBPASS $LDBNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment