How to synchronize website from locahost into ec2 amazon using rsync

We have files in our locahost and want to upload it into our ec2 amazon server using commandline. We know that AWS just support SSH as default main communication between client and server. FTP is difficult to be installed also SFTP will makes uploading time so long. Why don't use rsync as default command in Linux? We can synchronize files in our computer into ec2 server easily. Here are commandline for rsync between client and ec2 server :

In this example, we in directory where our .pem key located for easy managing. You want to syncronize content in YOURLOCAHOSTFOLDER into /var/www in your ec2 amazon server.
EC2 instance example is ubuntu@ec2-IP-ADDRESS.compute.amazonaws.com.

sudo rsync -avr /YOURLOCAHOSTFOLDER/* -e "ssh -i YOURKEYPEM.pem" ubuntu@ec2-IP-ADDRESS.compute.amazonaws.com:/var/www/

You can create this command as rsync.sh and execute by sudo sh rsync.sh.



You should follow me here

Comments

Hi,Thanks for that.but I have a problem,when I enter that command,it just hangs without doing anything.

Make sure you do the right command. Try with ssh into server first and check the correct path to synchronize.

Thanks,I was just on a slow link.

Exactly what I needed! Thanks! You were on #1 Google Results for me for "rsync .pem". Funny, uh?

LOL

Great and easy to follow instructions. Thanks.
PS. I had to remove "/" in "/YOURLOCAHOSTFOLDER" in order for me to wrok.

Add new comment