rsync: A Backup Strategy for Modern Times - Page 2

By  Carla Schroder | Jan 23, 2004
Page 2 of 4   |  Back to Page 1
Print ArticleEmail Article
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

rsync Commands

The following command makes copies on the same machine. The file or directory being copied is named first and the destination directory second:

$ rsync -a sourcedir destinationdir

To copy a directory from the local machine to a remote machine (note that rsync must be present on both machines):

$ rsync -a sourcedir remotehost:destinationdir


To copy a directory from the remote machine to a local machine:

$ rsync -a remotehost:/sourcedir destinationdir

It is best to be explicit and use full filepaths, even when copying from the current directory.


-a, or --archive, is shorthand for -rlptgoD:

  • r = Copy directories recursively. Without this switch, directories will not get copied at all.
  • l = Recreate symlinks.
  • p = Preserve permissions.
  • t = Transfer modification times and update them on the remote system. Must have this for accurate synchronization.
  • g = Set the group of the destination file to be the same as the source file.
  • o = Set the owner of the destination file to be the same as the source file.
  • D = Re-create character and block devices on the remote system (only root can do this).

To transfer over a ssh tunnel, use this command:

$ rsync -a -e ssh sourcedir username@remotemachine.com:/destinationdir/

-e ssh means "replace the native rsh protocol with ssh." If there is some other secure tunnel you want to use, this is where to name it.

Also, mind your trailing slashes, as they make a difference to rsync in the source arguments. A trailing "/" on a source argument means "copy the contents of this directory." Leaving off a trailing slash means "copy the directory and its contents."

Page 3: Dry-Run

Comment and Contribute
(Maximum characters: 1200). You have
characters left.
Get the Latest Scoop with Enterprise Networking Planet Newsletter
Helpful Links
  • Yankee Group Mobile WAN Optimization Report

    Mobile work continues to evolve. Your organization must keep up with the demands of its mobile workforce. This report introduces the concept of mobile WAN optimization and provides three case studies including RCM, PRTM and Einstein that highlight how this emerging technology can help IT departments achieve what previously appeared to be conflicting goals. Read >

  • Network Security Resources

    More threats than ever before pose a danger to today's enterprise network. Get the latest tips and intel on the newest risks in our guide to network security resources. Read >

  • Extreme Savings: Cutting Costs with WAN Optimization

    Did you know it's possible to cut IT costs without impacting day-to-day IT operations? In fact, when you download this whitepaper from Riverbed on cost-savings through WAN optimization, you'll discover how businesses of all different sizes have realized a return on investment in just a few months through significant hard cost savings in areas such as bandwidth reduction and IT consolidation. It's called Extreme Savings and its only from Riverbed. Read >