I'm using rsync to copy files between servers, I'm using -z option what compresses data only for the network transfer stage.

But I would like to leave compressed files on remote machine and I have not found this option in rsync.

Is this possible ?


No, it is not possible. You'll need to compress the data either before or after you transfer it.

  • Just curious : I'm interested in better understanding of zlib internals. Anyone has good documentation? – user130370 Aug 3 '12 at 12:43
  • Be aware that syncing uncompressed files (with on-the-wire compression) might be faster than syncing files that were compressed before they were synced. This is because the compression algorithm used beforehand might obfuscate commonality--preventing the rsync algorithm from taking advantage of it. This is probably only relevant if you want to use rsync to update a stale version of a compressed file. – MatrixManAtYrService Mar 21 '18 at 15:31

Short answer no.

Long answer : From what I understand of http://zlib.net/zlib_faq.html, zlib does not really compress files but chunks of a stream. You can't be sure that a total version of your file exists somewhere in a compressed state (think of sending a 200GB mp3 file : Do you need 190GB free space?).


The main reason why this is not possible is due to the nature of rsync. From the man page:

It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending only the differences between the source files and the existing files in the destination.

Unless this is the first time you are transferring these files, only the changes are being sent. If you could somehow save the data stream, you'd end up with a sort of compressed diff file, which wouldn't be of any particular use.

Compress the files before passing them to rsync.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.