Skip to content

Instantly share code, notes, and snippets.

@alotaiba
Created April 11, 2011 10:06
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save alotaiba/913313 to your computer and use it in GitHub Desktop.
Save alotaiba/913313 to your computer and use it in GitHub Desktop.
Using rsync to sync files to an Amazon EC2 instance using SSH key
rsync -avz /path/to/local/sync/folder -e "ssh -i /path/to/ssh/key" ubuntu@ec2instance:/path/to/remote/sync/folder
@gondolio
Copy link

gondolio commented Mar 2, 2014

Thanks!

@niczak
Copy link

niczak commented Oct 9, 2014

Works great but only seems to go one direction. If I delete a file/folder from the initial /path/to/local/sync/folder that change doesn't propagate to the ec2 instance(s). If I ADD a file it syncs over just fine, how can I adjust this so that deletes carry over as well?

@DaveOrDead
Copy link

You probably figured this out already, but if not I think you just add --delete after the -avz so:

rsync -avz --delete /path/to/local/sync/folder -e "ssh -i /path/to/ssh/key" ubuntu@ec2instance:/path/to/remote/sync/folder

@ronakpat
Copy link

unison is a good option. It is bidirectional and provides options how to handle conflicts.

@tanaysuthar
Copy link

tanaysuthar commented Mar 10, 2017

how rsync works from Ubuntu to Windows server scenario ?

rsync -avz /tmp/* administrator@54.175.177.128:/cygdrive/c/

Above command is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment