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.

[code]
# copy files from server1(local) to server2

rsync -avz /var/www/html/* user@server2.com:/var/www/html/

[/code]

Chris

Chris started building web sites and web applications in 1996, after installing Linux and discovering httpd. It was a career in freshwater fisheries and geographic information systems (GIS) that led Chris to the web, and to start Lanexa.net in 1998. Chris has a strong background in Linux/Unix systems administration, HTML, CSS, PHP, as well as Oracle and MySQL database administration. Chris is a proven leader, having lead the development of ecommerce platforms for Fortune 500 companies, as well as start ups. He is able to bridge the gap between Marketing and IT, and turn business requirements into development objectives, and he delivers results. When Chris is not working on web sites, he is usually chasing his kids around or playing mandolin. Finalist, San Diego Magazine's Top Tech Exec Awards, 2012, 2013 Council Member, Magento X-Commerce Merchant Council, 2011

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

  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.

Leave a Reply

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