Table of Contents




Rsync remote synchronization is a free software for the synchronization of files, available under the GNU GPL license. The synchronization is unidirectional, this means the files are copied from a source to a destination target. RSync can be used to make an incremental or decremented backup or to diffuse the content of a reference folder.

“rsync” is available for a wide range of operating systems (Microsoft Windows, GNU/Linux, Mac OS X, Unix) and does also allow the transfer of files from different operating systems.

Source :


Create a mirror of a folder

One of the main feature is RSync synchronizing a local folder to a remote folder (or vice versa!)..

This allows to have an exact copy of an existing folder on a remote location, mainly in the context of a backup.

rsync -a source/ destination/
The source or destination of the files can be remote, as seen with SCP

Here, the argument “-a” will be use for several things:

        -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
  • Recursion
  • Copy symbolic links as symbolic link
  • Conservation of permissions
  • Conservation of modification dates
  • Conservation of the group
  • Conservation of the owner
  • Transfer of specific files

This is the most basic mode of RSync and often used with the option “-v” for verbose mode.

A perfect copy

The method described above works perfectly well, but does not affect deletions from the source folder to the remote folder by default.

For example, you have a file “file.txt” in the source folder and you are synchronizing it for the first time, the file will also be present in the destination folder.
If you delete the file in the source folder and synchronize the folder again, the file will remain present in the destination folder.

If you don't want this behavior, here is what to do:

 rsync -av --delete-after source/ destination/

The option –delete-after allows to pass on deletions after copying has taken place, which is usually the preferred behavior.


Often you want to synchronize a directory but with the exception of a certain sub-folder.

The option –exclude is available for this.

Let us say we want to do a backup of our entire server (/), but we don't want to save the specific folders /proc & /dev.

Therefore we will exclude them from our backup:

rsync -av --exclude=/dev --exclude=/proc / destination/

Best practices & Compression

A command to remember, that can be useful for you in all situations:

rsync -avhP source/ destination

Let's see new arguments :

  • -h : for “humanize”. Transforms bytes to Kilo/Mega/Gigabytes to make it more easy to read.
  • -P : for “Progress”. Displays the process of the transfer in real time (with -v, it will display the process file by file).

This command will allow you to synchronize a complete file, while showing the progress.

RSync also has the advantage of being able to pick up a transfer at the point where it was interrupted when copying. This is useful when you have a problem with your Internet connection.
The compression : z

The option -z allows to compress the files before they are transferred to save bandwidth.

This option is usually preferred, except for transfers over a high speed connection. RSync is by default mono-threaded and the compression process requires more CPU power, resulting in a slower transfer speed.

We invite you to contact the manPage of RSync for more details :

man (1) rsync