Skip to content

Instantly share code, notes, and snippets.

@dux
Created November 13, 2011 00:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dux/1361327 to your computer and use it in GitHub Desktop.
Save dux/1361327 to your computer and use it in GitHub Desktop.
MYSQL database pull from remote server (heroku like)
#!/bin/bash
FILE="/var/www/${1}.sql"
echo "Delete remote dump [${FILE}]"
ssh root@178.79.163.176 "rm -rf ${FILE}"
echo "Remote database dump"
ssh root@178.79.163.176 "mysqldump --user=root --password=XYZ ${1} > ${FILE}"
# echo "Deleting local backup"
# rm -rf "${1}.sql"
echo "Backup download"
scp "root@178.79.163.176:${FILE}" .
echo "Backup import"
mysql --user=root $1 < "${1}.sql"
echo "Finito!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment