The syntax of writing and executing the rsync command is really simple.
In the above-given syntax, we first have to provide the options to the rsync command and later provide the source from where you want to transfer the data or files and destination path.
The most common options used in the rsync command are as follows:
-a option is for archive files and folders during synchronization,
-r is for synchronizing the files in recursive mode,
-v is for verbose output,
-b is for keeping the backup during the synchronization,
-z is for compressing and transfer the files,
-progress is for showing progress.
Installation of rsync command
Usually, the rsync command is already available in all Linux-based operating systems, but it does not come pre-installed in the minimal installation of an Operating system.
To install rsync in Ubuntu or any Debian based Operating system, use the command given below:
To install rsync in CentOS or RHEL based Operating system, use the command given below:
Rsync Command syntax for remote transfer
The syntax of the rsync command for remote transfer is a bit different. We have to provide the username and the IP address of the remote host where we want to transfer files using the syntax provided below:
Local to Remote Transfer
For transferring files from the local system to a remote system, you need to use the syntax given below:
Remote to Local
For transferring files from any remote host to the local system, you need to use the syntax given below:
Now, you have all the basic and required knowledge of the rsync command; let’s understand how to rsync to multiple destinations.
How to rsync to multiple destinations
The answer to either rsync provides any method or options to transfer files to multiple destinations, or not is short NO. There is no method available to provide multiple destinations to the rsync command. Rsync works only from point to point.
However, using some manual techniques, we can use any loop and invoke the rsync command multiple times.
Rsync to multiple destinations using for loop
For loop is a great choice to provide multiple destination paths and run the rsync command for transferring the data to multiple destinations instead of executing the rsync command manually again and again.
The syntax for writing the for loop and providing multiple destinations is as follows
> do rsync -options SOURCE_PATH $d
Using this technique, you can provide multiple destinations and transfer the data to multiple destinations using the rsync command.
Rsync is a command used for transferring files or directories from one place to another efficiently by just transferring the changes instead of the whole data again and again while back up or mirroring operations. This post provides the basic syntax, its usage, and installation method in any Linux-based Operating system. This post provides an interesting and useful technique for transferring the data to multiple destinations using the loop and rsync command.