Skip to content

Instantly share code, notes, and snippets.

@sr75
Created September 17, 2013 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sr75/6594102 to your computer and use it in GitHub Desktop.
Save sr75/6594102 to your computer and use it in GitHub Desktop.
mysql backup and download to dev desktop for a local restore

Say you ssh into a server as the user deployer and have a folder on the server ~/dump:

# on the server you are logged into
# backup the database
mysqldump -uroot -pstrongPassword railsapp_staging > ~/dump/YYYYMMDD_railsapp_staging.sql

# next logout/exit your ssh session to the server above
exit

# now download the backup from the above server
# say you have a folder db/dump in the local folder you are in
scp deployer@aboveserver.com:dump/YYYYMMDD_railsapp_staging.sql db/dump/.

# restore from backup file to local development mysql
mysql -uroot -plocalPassword railsapp_staging < YYYYMMDD_railsapp_staging.sql  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment