Sunday, January 2, 2011

Simple and powerful: rsync

rsync is a software application for Unix systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction. 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 of 873, serving files in the native rsync protocol or via a remote shell such as RSH or SSH. In the latter case, the rsync client executable must be installed on both the local and the remote host.
Released under the GNU General Public License, rsync is free software. It 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. Like its predecessors, it still requires a source and a destination to be specified, one of which may be remote. Because of the flexibility, speed and scriptability of rsync, it has become popular with many system administrators. As a result, rsync has been ported to Windows (via Cygwin), Mac OS and GNU/Linux.

Possible uses:

One of the earliest applications of rsync was to implement mirroring or backup for multiple Unix clients to a central Unix server using rsync/ssh and standard Unix accounts.
With a scheduling utility such as cron, one can schedule automated encrypted rsync-based mirroring between multiple hosts and a central server.

The basic usage to synchronize two folders looks like:
rsync -rtv /source_folder /destination_folder

This overwrites existing files on the destination_folder having the same name as files in source_folder. The -r option allows for recursion into subfolders. If you want to preserve newer existing files from overwriting, you can type:
rsync -rtvu /source_folder /destination_folder

or if you want to backup existing files before overwriting them:
rsync -rtvb /source_folder /destination_folder

If you want more information, please open a terminal in your system and look at the rsync's man page: man rsync

Thanks wikipedia ;)