Use rsync to transfer files between Linux servers

Chris Support 3 Comments

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/* user@server2.com:/var/www/html/

Comments 3

  1. 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]

  2. 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/* user@remote-server.com:/var/www/html/*

    this will put all the files in the /var/www/html directory in the remote-server.com at the same location.

    1. Post
      Author

Leave a Reply

Your email address will not be published. Required fields are marked *