Rsync is an application and network protocol for Unix type systems that synchronizes files and directories from one location to another while minimizing the transfer using delta encoding when possible.
The rsync command (available on servers or computers running Linux or UNIX) comes from remote sync that might translate with “remote synchronization.”
Rsync is used to synchronize files and folders from one location to the other in a practical location. The location where the data can be hosted can be both on the local server and on a dedicated remote server.
Some features of rsync:
1. Privileges – rsync does not require special privileges to be installed or used.
2. Speed - rsync reproduces the entire content between source and destination when executed for the first time. Subsequently, rsync will only transfer the modified blocks or bytes to the destination; for this reason, the transfer is high-speed.
3. Security – rsync allows data encryption using the SSH protocol during transfer.
4. Bandwidth – rsync uses, for transfer, compression and decompression of block by block data, resulting in very low bandwidth usage compared to other transfer methods.
RSync can also be used for backup
If we need a quick backup without headaches and without interest in compressing data we can use rsync. rsync is a command that allows us to synchronize two directories locally or remotely. For a quick backup, let’s assume that we have a home partition with important data and a different partition backup on a different HDD for backup. For backup, we use rsync to synchronize the contents of the home directory with the contents of the backup directory:
rsync -au / home / backup
The parameter tells the application that everything must be synchronized in archive mode and the -u parameter tells the app that the files need updating only if needed; if the backup file is newer than the original, it will not be overwritten. To save space, you can also use the delete parameter that will delete files that are no longer found in home.
One more thing, rsync makes incremental updates to the directory. If you give the same command later, only newly created or modified files/folders will be copied. This is a great thing when you do not want to copy the whole directory again because it would take a long time. Rsync will make a difference between the source and the target and only copy what is added or modified since the last synchronization.
Other options worth mentioning are:
–v: makes rsync more tedious; it will show you step by step what it does, including what you copy and where.
–x: If there is another partition or other file system under the folder you are copying, it will not be added to the copy list (for example, let’s say you have a home folder on a separate partition; the home directory will be created on the backup drive, but its contents will not be copied).
–Delete-excluded: Normally, if you delete a file from the source directory, rsync will not delete it from the target directory, but if you want to have an exact copy of the source tree and destination, then this option will also delete the files that disappeared from the source from the last rsync.