Skip to content
Latchkey

rsync -z: Compression for Slow CI Links

rsync -z compresses file data during transfer, trading CPU for less bandwidth.

When a CI deploy crosses a slow or metered link, -z can cut transfer time. Over a fast LAN it can actually slow things down.

What it does

-z compresses the file data stream before sending it and decompresses on the other end. It helps most for text-heavy artifacts (HTML, JS, JSON, source) over a constrained link. It rarely helps for already-compressed files (images, .gz, .zip, video) because they do not shrink and you pay CPU for nothing.

Common usage

Terminal
# Compress a JS bundle deploy over SSH
rsync -avz dist/ user@host:/var/www/

# Skip compressing files that are already compressed
rsync -avz --skip-compress=gz/zip/jpg/png/mp4 dist/ user@host:/srv/

Compression options

FlagWhat it does
-z / --compressCompress file data in transit
--compress-level=NSet zlib level 1-9 (higher = more CPU)
--skip-compress=LISTSuffixes to send uncompressed
--compress-choice=zstdPick the algorithm (rsync 3.2+: zstd, lz4, zlibx)

In CI

On a fast same-region link (for example a runner deploying to a server in the same cloud), -z often makes deploys slower because the CPU cost exceeds the bandwidth saved. Benchmark a real deploy both ways. For cross-region or home-server targets, -z usually wins.

Common errors in CI

On older rsync, requesting --compress-choice=zstd against a daemon or peer that lacks it fails with something like "compress-choice=zstd not supported". Drop the explicit choice and use plain -z, or upgrade both ends to rsync 3.2+.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →