Use rsync to transfer files between Linux servers

We use rsync to transfer files across servers and to assist with a variety of tasks associated with backup and restore. We found this great tutorial over at Nixcraft. Check it out. They do a great job of explaining advanced uses of rsync.

In a nutshell, this is one of the most useful commands we use and thought we would share with you.

# copy files from server1(local) to server2

rsync -avz /var/www/html/*


3 Responses to “Use rsync to transfer files between Linux servers”

  • Miguel Mota says: Jun 23, 2014 at 8:07 am

    Thanks for this, but I got the following error: The source and destination cannot both be remote. rsync error: syntax or usage error (code 1) at /SourceCache/rsync/rsync-42/rsync/main.c(1083) [receiver=2.6 .9]

  • Mauricio Aguirre says: Nov 6, 2014 at 11:39 pm

    The error is because rsync doesn't allows to transfer files between remote servers, instead you must use one local (source or destination) and one remote. For example, rsync -avz /var/www/html/** this will put all the files in the /var/www/html directory in the at the same location.

    • Chris says: Nov 22, 2014 at 6:35 pm

      Mauricio is correct. I'm usually logged into the remote server1 when kicking off rsync. ;-) Thanks for clarifying this. I will revise the post.

Leave a Comment