Skip to content

Instantly share code, notes, and snippets.

@openrijal
Created February 8, 2014 15:22
Show Gist options
  • Save openrijal/8885353 to your computer and use it in GitHub Desktop.
Save openrijal/8885353 to your computer and use it in GitHub Desktop.
This bash script is to be run from local machine and it copies remote web files and database to local folder.
# Assumptions
#########################
# remote_host: example.com
# remote_user: johndoe
# db_user: mydbuser
# db_pass: mydbpass
# db_name: mydbname
# to dump mysql database in the remote system from local system
ssh johndoe@example.com 'mysqldump -u mydbuser --password=mydbpass mydbname > /destination/path/dump_filename.sql'
# to sync remote folder with local folder (incremental sync)
rsync -ravz --progress -e "ssh -l johndoe" --delete example.com:/path/of/remote/folder/ /path/of/local/folder/
# References
# 1. SSH Man Page:- http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1
# 2. RSYNC Man Page:- http://linux.die.net/man/1/rsync
# 3. Passwordless SSH Login: http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment