Login

Rsync

rsync is a file synchronization and file transfer program for Unix-like systems that minimizes network data transfer by using a form ofdelta encoding called the rsync algorithm. rsync can compress the data transferred further using zlib compression, and SSH orstunnel can be used to encrypt the transfer.

rsync is typically used to synchronize files and directories between two different systems, one local and one remote. For example, if the command rsync local-file user@remote-host:remote-file is run, rsync will use SSH to connect as user to remote-host.[4] Once connected, it will invoke another copy of rsync on the remote host, and then the two programs will talk to each other over the connection, working together to determine what parts of the file are already on the remote host and don’t need to be transferred over the connection.

rsync can also operate in daemon mode, where it listens by default on TCP port 873, serving files in the native rsync protocol (using the “rsync://” syntax).

It is released under the GNU General Public License version 3 and is widely used.

Uses

rsync originated as a replacement for rcp and scp. As such, it has a similar syntax to its parent programs.[11] Like its predecessors, it requires the specification of a source and of a destination; either of them may be remote, but not both. Because of the flexibility, speed and scriptability of rsync, it has become a standard Linux utility, included in all popular Linux distributions. It has been ported to Windows (via Cygwin, Grsync or SFU) and Mac OS.

Generic syntax:

rsync [OPTION] … SRC [SRC][USER@]HOST:DEST
rsync [OPTION][USER@]HOST:SRC [DEST]

…where SRC is the file or directory (or a list of multiple files and directories) to copy from, and DEST represents the file or directory to copy to. (Square brackets indicate optional parameters.)

rsync can synchronize Unix clients to a central Unix server using rsync/ssh and standard Unix accounts. It can be used in desktop environments, for example to efficiently synchronize files with a backup copy on an external hard drive. A scheduling utility such as cron can carry out tasks such as automated encrypted rsync-based mirroring between multiple hosts and a central server.

Examples

A command line to mirror FreeBSD might look like:

 % rsync -avz --delete ftp4.de.FreeBSD.org::FreeBSD/ /pub/FreeBSD/

The Apache HTTP Server supports only rsync for updating mirrors.

rsync -avz --delete --safe-links rsync.apache.org::apache-dist /path/to/mirror

The preferred (and simplest) way to mirror the PuTTY website to the current directory is to use rsync.

rsync -auH rsync://rsync.chiark.greenend.org.uk/ftp/users/sgtatham/putty-website-mirror/ .[15]

A way to mimic the capabilities of Time Machine (Mac OS) – see also tym.

#date=`date "+%Y-%m-%dT%H:%M:%S"`
date=`date "+%FT%T"`
rsync -aP --link-dest=$HOME/Backups/current /path/to/important_files $HOME/Backups/back-$date
ln -nfs $HOME/Backups/back-$date $HOME/Backups/current
About the Author