rsync

From Peyton Hall Documentation
Jump to navigation Jump to search

rsync is a program that can synchronize files between two locations. It can be used to sync files on local disks, NFS mounted disks, or even over the network via SSH. It is quite powerful in its ability to scan two file trees and copy over only what is necessary to make them equal.


Basic usage

rsync -avue ssh source_machine:/dir dest

This will synchronize all the files from "source_machine"'s "/dir" directory to the local directory "dest". Note that this is one way, so if you want to sync files in both directions, you have to repeat the command, swapping the order of source and destination. The '-e' option, and corresponding 'ssh', tells rsync to use ssh to do the transfer.

NOTE:

The presence or absence of a trailing slash on the directories does make a difference!

rsync -avue ssh coma:/u/user/WWW .

Create a directory in the current directory named WWW, and copy the contents of the remote dir to the source. It's like copying /u/user/WWW to the current directory.

rsync -avue ssh coma:/u/user/WWW/ .

Copy the contents of /u/user/WWW to the current directory, and not the directory itself! This is important if you're trying to synchronize two file systems that started as a copy of each other, but are now slightly different, as you want to make sure the source and destination are the same as they were in the original copy.


Documentation

'man rsync' for more (lots more) details. Also have a look at the rsync homepage, http://rsync.samba.org, especially if you're looking for a binary compiled version to run on a remote machine. Last, there's a rsync tutorial at http://everythinglinux.org/rsync/ which is very informative.