User Tools

Site Tools


technology:linux:how_to_use_rsync

How To Use rsync

This page isn't a comprehensive guide to rsync1). Instead, this is my quick reference to synchronizing a remote directory with a local one using rsync.

First, the scenario: Machine 1 contains a constantly-changing set of files that I want to sync to a different directory on Machine 2. I could login to either machine to complete the rsync, but I'll login to Machind 1 and “push” the files to Machine 2. The scenario is best illustrated like this:

The files I'm syncing are TV recordings. They won't be modified once they reach their destination (although rsync could handle that), but the set of files on Machine 1 changes slightly each day. The most important thing is to add and delete files from Machine 2 to keep it in sync with Machine 1.

Here is the statement that causes the sync to happen:

cd /video
nohup rsync -r -a -v -e "ssh -l myIdOnMachine2" --delete tvrecordings/ Machine2:/data/mythtv/recordings/

Its a powerful command:

  • -r = recursive
  • -a = archive (copying owner, group, permissions, etc…
  • -v = verbose (optional)
  • -e = name of remote command to use
  • –delete = delete unneeded files from destination directory

Its critical to note that the source directory is listed first, and the destination directory is synced to it. If you reverse these, the process will work in reverse–syncing your source directory to the destination.

1) If you need that, please see the man page
/home/cfreyer/public_html/data/pages/technology/linux/how_to_use_rsync.txt · Last modified: 2010/03/08 15:34 by Chris Freyer