Rsync is a command-line utility for synchronizing files and folders between locations. Some workflows that can be implemented with rsync include updating a production host on a developer or calling rsync via cron to save the data backup to a storage location on a regular basis. You can even use rsync to migrate your server from another provider to Microhost.

Because Rsync is incremental, subsequent backup operations are completed very quickly once the initial operation is completed. Only the differences between the source and target files are copied. This rsync property is best suited for automated operations.

Install rsync on linux

Linux / Unix: Not all * nix systems include rsync by default, but it can be installed from your distribution’s software repository or compiled from source. To install the rsync package, run the command below.

[[email protected] ~]# yum install rsync -y

Working With rsync

Many options are available for use with rsync, and many people have their preferred set of options when using this tool. Single rsync options can also be aliases for multiple others, so rsync -a produces the same results as rsync -rlptgoD.

So rsync is a device for which you should exercise extreme caution when copying commands from forum posts and other websites on the internet without fully comprehending what they are doing. You will get the most out of rsync if you take the time to investigate and experiment before using your data.

To get started with rsync, you’ll need the following two commands:

[[email protected] ~]# man rsync
[[email protected] ~]# rsync -help

The basic structure of an rsync command is the same as that of cp and SCP.

[[email protected] ~]# rsync -[argument] source destination

When you have multiple destinations, they are all connected to the end of the string in the same way that the cp command does:

[[email protected] ~]# rsync -zarvh source loation1 location2 location3

Either the source or the destination can be nearby or far away, or both. If you are synchronizing files across a network, rsync must be enabled on both the local and remote machines. Rsync employs SSH to encrypt data as it travels across networks, and it works with SSH keys to easily authenticate remote servers.

Remote commands, such as SSH or SCP, are formatted. To synchronize a local folder with one on a remote server, for example, you would use:

[[email protected] ~]# rsync -zarvh /path_of _source_folder [email protected]:/path_of_destination_folder

To synchronize a remote location folder on your local machine, follow these steps:

[[email protected] ~]# [[email protected] ~]# rsync -zarvh [email protected]:/path_of_destination_folder  /path_of _source_folder