The —compress-level option in Rsync is designed to specify and control the compression level of data for transfer purposes. This option is generally designated with a numeric value – from 0 to 9- where 0 indicates no compression and 9 indicates maximum compression.
Rsync (Remote Sync) is an open-source utility that is widely used for Unix-based systems to synchronize and transfer files across both local and remote systems. Its capability to capture only the differences (delta) of the files being transferred makes it highly efficient tool for data replication and backup. The usage of compression makes Rsync not only effective but also data-saving.
The —compress-level option (-z level) allows you to tweak the trade-off between the amount of compression (and thus, the CPU usage) and the transfer speed. A low number means less compression (forwarding more data over the network, but using less CPU), whereas a high number means more compression (forwarding less data over the network, but using more CPU).
In Rsync, the default compression level, if no level is specified, is 6, which is slightly biased towards higher compression. This could save network bandwidth at the cost of CPU; however, it might not be the optimal setting for all use cases (for example, very large files, slower CPU, etc.).
Here’s an illustrating example:
`rsync -avz —compress-level=9 source_directory/ destination_directory/`
This command will replicate the source directory into the destination directory, compressing data to level 9 during transmission.
It’s important to comprehend that the —compress-level option is only effective if Rsync is also invoked with the —compress (-z) option, which enables compression in the first place. Without the -z flag, the —compress-level option will be ignored.
The information regarding the Rsync compression level could be found in the Rsync man page that serves as the primary documentation for Rsync.
Sources:
- “Rsync man page”, www.samba.org , [Link](https://www.samba.org/ftp/rsync/rsync.html)
- “Rsync (Remote Sync): 15 Practical Linux Examples”, The Geek Stuff, [Link](https://www.thegeekstuff.com/2010/09/rsync-command-examples/)
- “Understanding Rsync: Linux command for backup and sync files/folders”, GoLinuxCloud, [Link](https://www.golinuxcloud.com/rsync-command-examples-linux/)