Rsync

From Wsms

Jump to: navigation, search

Note: This page should be titled rsync (all lowercase). It is rsync due to technical limitations of Mediawiki.

rsync is a backup utility. It can operate locally or over the network via ssh. It is very efficient in comparing directory and files and only copies the parts that have actually changed.

common usage

This command uses ssh to copy a directory tree across the network preserving the file attritubes:

[ggeller@ws05 public_html]$ rsync -av php/ georgeg@rop.ncc.sdccd.net:public_html/php/
georgeg@rop.ncc.sdccd.net's password:
building file list ... done
./
20070321/
...

Tips

Use the -n option to see what would be copied without actually performing the action.

You can set an ssh key up so that you don't have to log in manually. See Rsync_with_ssh_keys.

Sirhc reports two rsync implementations that work with Windows: "I've used rsync-over-ssh using cygwin. Alternatively, winscp has a sync feature"

You can exclude an entire directory tree (or a single file) with the --exclude directive.

[ggeller@ws05 rsync-test]$ rsync --exclude=archive -avn source/ dest/

Limit the bandwidth usage with the --bwlimit flag:

ggeller@grant:~$ rsync -av --bwlimit=32 /home/ggeller/backup hayes_backup@cleveland:

Sometimes it is tricky to specify directory names if they have spaces in them. You need to use both quotes and backslashes. Alternatively consider using an *.

[ggeller@localhost test]$ rsync -av '192.168.2.12:/mnt/sda5/vmware/Virtual\ Machines/Windows\ XP\ Professional' .
...

see also

man rsync
Linux_commands
Rsync_with_ssh_keys

Personal tools