Votes: 0Posted On: Jul 11, 2017 02:04:28
"rsync" is a versatile copying tool provided by Linux distributions. It is used to copy files locally to/from a remote host over any remote shell. rsync is best used for synchronization of files in the case of backup and mirroring. You can keep your data safe by copying sensitive data to the remote host and retrieving it whenever required. It also contains options through which you can perform operations. The "rsync" command updates the folder by adding the new files to be copied and avoid the overwriting of files.
1. "rsync" should be installed on your system. To check if rsync is installed, run the following command.
2. If the rsync command is not installed, install it by running the following command.
RPM based Operating Systems - yum -y install rsync
Debian/Ubuntu - apt-get install rsync
3. Make sure that the IP is whitelisted on the firewall of both the remote and local system.
4. An established SSH connection between remote and local machine.
A Push Operation
Copying of files from local to remote system is called a "push" operation. The syntax of the command is as follows.
rsync -a path_of_local_directory username@remote_host:destination_directory
A pull operation
Copying of files from remote to local machine is called a pull operation. The syntax of the command is as follows.
rsync -a username@remote_host:path_of_remote_directory place_to_sync_on_local_machine
The "rsync" command has a lot of options to use with it. Some of the important options are discussed below.
# "-a" option is the same as -rlptgoD. Here are some of the functions that "-a" option performs.
1.Descend recursively into all directories (-r),
2.copy symlinks as symlinks (-l),
3.Preserve file permissions (-p),
4.Preserve modification times (-t),
5.Preserve groups (-g),
6.Preserve file ownership (-o), and
7.preserve devices as devices (-D).
# "-z" option is used to compress files while sending them.
# "-P" option is the same as --partial and --progress.
--partial - It is used to resume the interrupted transfers.
--progress - It is used to display the progress bar of the transfers.
# "-v" - It is used to display the result in a more verbose manner.
The "rsync" command comes with numerous options. It is recommended to use the "man" command with rsync to master all the options. The command is as follows.