Does Compression Option -z with rsync Speed Up Backup?

The “rsync” is the popular built-in utility of Linux utilized for syncing the directory/file from one location to another. The compression option “z” of the rsync command speeds up the backup that is based on various factors. These factors include size, types of files, network connection, CPU performance, and many more.

This post will answer the question “Does Compression Option -z with rsync Speed Up Backup?” with the help of examples.

Using rsync Command with “z” Flag 

In the “rsync” command, the “z” flag compresses the data before it is sent. This process reduces the amount of data which improves the backup speed especially when the user is dealing with large files or slow networks. 

Let’s practice different examples of the “rsync” command.

Example 1: Enable Compression in rsync to Backup Locally

To create the backup by applying compression, the following syntax is carried out:

Syntax

$ rsync -azv [Source Directory/Path] [Destination Directory/Path]
  • rsync” command to create a backup 
  • The “a” to preserve the symbolic link, file permissions, and modification time.
  • The “z” flag to apply compression.
  • The “v” flag to enable verbose mode.
  • Enter the “Source Directory/Path” of the directory to be backed up.
  • Then enter the “Destination Directory/Path”.

Let’s apply compression while creating the backup for the following “Dir1” directory. The content in the particular directory can be displayed via the “ls” command as below:

$ ls

The “Dir1” directory has two text files and one ISO file of Linux Mint.

To apply the compression while creating a backup of the “DIr1” to the “Dir2” directory as follows:

$ rsync -azv Dir1 Dir2

The backup for the “Dir1” is created with the speed up of “1.02

Example 2: Enable Compression and Upload Backup to the Remote Host

To create the backup and upload them to the remote host, specify the source path, remote host and the destination path in the following syntax.

Syntax

$ rsync -avz [Source Path] Remote@host:[Destination Path]
  • rsync” command to create a backup 
  • The “a” to preserve the symbolic link, file permissions, and modification time
  • The “v” flag to enable verbose mode.
  • The “z” flag to apply compression
  • Enter the “Source Path” of the directory to upload.
  • Then enter the remote host with “Destination Directory/Path”.

The below command applies the compression and creates the backup of “Dir1” to the “Henry” directory of the remote host:

$ rsync -avz ~/Dir1 Henry@ubuntu:Henry

The backup for directory “Dir1” is uploaded to the remote host with speedup “1.02”.

Example 3: Create a Backup Without Compression

Now, let’s try to create a backup without compression to check the speed of the backup data. The following command creates the backup of the “Dir1” to the remote host directory “Desktop”:

$ rsync -av ~/Dir1 Henry@ubuntu:Desktop

The backup is uploaded with speedup “1.00“.

From the above examples, the speed up with or without compression is almost the same “1.02” and “1.00“. So, there is no need to apply compression in our scenario. However, the user can utilize it when dealing with large files.

Conclusion

Yes, the “z” option of the rsync command speeds up the backup in specific scenarios depending on the factors. The factors are size, types of files, network connection, and CPU performance. The “z” option transfers the data by compressing files/directories. 

This write-up has illuminated the answer to the saying “Does Compression Option -z with rsync Speed Up Backup?”.