rsync: A Backup Strategy for Modern Times - Page 3

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

Dry-Run

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

The -n switch, or --dry-run, shows what will happen when rsyn is run but without actually copying or changing anything. Use with -v, verbose, to see the messages. Verbose has three levels: -v, -vv, and -vvv for maximum verbosity. Always perform dry runs until you're satisfied rsync will work as desired.

Some other useful command options to be aware of include:

  • --delete = Use with caution! Always do a dry-run first when using --delete. Don't say I didn't warn you! --delete removes all files at the destination that do not exist on the source.

  • --delete-excluded = Delete any files that are named by --exclude. As you can see, this is powerful stuff to keep archives tidy and uncluttered. Use it wisely.
  • -z (or --compress) = Use rsync's compression.

  • -S (or --sparse) = Handle sparse files efficiently.

  • -H (or --hard-links) = Preserve hard links. -a does not preserve hard links.

  • -b (or --backup) = Appends a ~ to existing destination files. You're not stuck with "~", as the --suffix command lets you specify anything you like
  • --backup-dir=DIR = Combine with --backup to tell rsync where to store backups.

Excluding Files

rsync can be exclusive as well as inclusive:

--exclude pattern = Exclude files matching pattern.

--exclude-from file = Exclude patterns listed in file.

For example, --exclude *.tmp will exclude all .tmp files. --exclude *.bak excludes .bak files. Name individual files and directories. Each --exclude can take only one argument. For multiple excludes, either string them together on the command line:

--exclude *.bak --exclude *.tmp

Or better, put them in a file:

--exclude-from exclude.file

rsync now supports regular expressions, as all good Linux programs should, for fine-grained file selection. It requires applying a patch; follow this link for details.

Page 4: Running an rsync Server

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 >