Nov 10, 2018

rsync - synchronizes files and directories from one location to another

rsync is a file transfer program for Unix systems. rsync uses the 'rsync algorithm' which provides a very fast method for bringing remote files into sync. A feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction, eliminating the message latency overhead inherent in transmitting a large number of small messages. rsync can copy or display directory contents and copy files, optionally using compression and recursion.

In daemon mode, rsync listens on the default TCP port, 873, serving files in the native rsync protocol. (That's using the "rsync://" syntax.) You can also implicitly start it through a remote shell such as RSH or SSH.

Released under the GNU General Public License version 3, rsync is free software, and is widely used.

rsync was originally written as a replacement for rcp and scp. As such, it has a similar syntax to its parent programs.

rsync is typically used to synchronize files and directories between two different systems. 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. Once connected, it will invoke the remote host's rsync and then the two programs will determine what parts of the file need to be transferred over the connection.

rsync can also operate as a daemon mode serving files in the native rsync protocol (using the "rsync://" syntax).

Typical usage (as a cron job every minute):

* * * * * rsync -az --delete* /backup/path
This is to pull, you can switch source and target as push.

From command line, verbose output:

$ rsync -avz --delete  /live/path*

-a, --archive
This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission).
-v, --verbose
This option increases the amount of information you are given during the transfer. By default, rsync works silently. -suitable for cron job.
-z, --compress
With this option, rsync compresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted -- something that is useful over a slow connection.

See also:

Two useful gsutil commands: rsync and signurl