Rsync Command Options - Explained with Examples

RSYNC stands for remote synchronization, and it is a multi-purpose tool that is mainly used for transferring data from one location to another. Moreover, it is also used for data synchronization between different storage locations. These storage spaces can either be remote or local, i.e., you can even use this tool for synchronizing and transferring data to a remote location. 

Here at LinuxAPT, we shall look into the options associated with Rsync and helpful examples to demonstrate its usage.


RSYNC Command Options

The RSYNC command in Linux offers different options that can be paired up with this command to produce the desired results. 

To learn about all these options, all you need to do is to run the below command:

$ rsync --help

All the options of the RSYNC command, along with their detailed description, are stated in the help manual of this command.

The most commonly used options of the RSYNC command are:

  • -a: This option is used for copying files recursively while preserving all the symbolic links, file permissions, timestamps, etc. It is known as the archive mode.
  • -v: This option is used for displaying the details about the data being transferred during the execution of the RSYNC command. Moreover, it also displays a summary of the whole transaction at the end of the execution. This option stands for verbose.
  • -h: This option is simply used for displaying the output of the RSYNC command in the human-readable format.
  • –progress: This option is used for displaying the progress of the ongoing data transfer.


RSYNC Command Examples

1.  Using the RSYNC Command for Listing the Contents of a Directory

Here, we want to use the RSYNC command for listing the contents of a directory with the RSYNC command:

$ rsync /home/system/Temp1/

Whenever we use the RSYNC command along with a directory without specifying any other options, then it works just like the "ls –l" command and displays the contents of the specified directory. In this particular example, we wanted to display the contents of the "Temp1" directory. 

The contents of this directory will be displayed. This output not only presents the contents of the said directory but also specifies the access permissions of this directory as well as all of the files and sub-directories.

Similarly, you can use this command to display the contents of any directory of your system simply by replacing "/home/system/Temp1/" with the exact path of your particular directory.


2. Using the RSYNC Command for Copying the Contents of a Directory to Another

Now, we will use the RSYNC command for copying the contents of one directory to another by running the RSYNC command:

$ rsync –avh /home/system/Temp1/ /home/system/Temp2/

This command will simply copy all the contents of the "Temp1" directory to the "Temp2" directory. The "avh" options will display the output in human-readable format along with all the relevant information.

To confirm if the contents of the directory "Temp1" have been successfully copied to the directory "Temp2", we will display the contents of the "Temp2" directory by running the command:

$ rsync /home/system/Temp2/

The output will show that all the contents of the directory "Temp1" have been successfully copied to the directory "Temp2".


3. Using the RSYNC Command for Displaying the Copying Progress

Again, we will use the RSYNC command to display the progress while copying the contents from one directory to another by running the below command:

$ rsync –avh --progress /home/system/Temp1/ /home/system/Temp2/

The "progress" option is used for displaying the copying progress.

This option is particularly useful in situations where you are copying large files from one location to another that take up a reasonably long time.


[Need help in fixing Linux System issues ? We can help you. ]

This article covers a few options of the RSYNC command along with a few examples that elaborated on the usage of this command. In fact, with rsync, you will be able to use this tool very efficiently for transferring data from one location to another.


What is the Rsync Command Syntax ?

The syntax for the rsync command changes depending on the usage of the tool. We will cover all the scenarios in the following examples. Rsync syntax in its most basic form looks like this:

$ rsync options SOURCE DESTINATION


Remote data transfers require you to specify a host's address, but more on that later.


What are Rsync Command Options ?

The rsync tool comes with many options. You can enter rsync in your terminal and get all the details. We will list some of the most common rsync options:

  • -r Allows to sync data recursively but does not keep ownership for users and groups, permissions, timestamps, or symbolic links.
  • -a The archive mode behaves like the recursive mode but keeps all file permissions, symbolic links, file ownership, etc.
  • -z Used to compress data during transfers to save space.
  • -b Performs a backup during data synchronization.
  • -h Shows the numbers in the output in a human-readable format.
  • -n Does a dry run. Used for testing before the actual synchronization takes place.
  • -e Instructs the rsync to use the SSH protocol for remote transfers.
  • -progress Displays the transfer progress during synchronization.
  • -v Verbose output. Displays the details of the transfer.
  • -q Used to suppress the output for the rsync command and options.

Related Posts