Skip to main content

Compression & Bandwidth

When to Compress

ScenarioUse -z?Why
Remote server (WAN)YesSaves bandwidth
Local transferNoCPU overhead, no benefit
LAN (1 Gbps+)NoNetwork faster than CPU
Already compressed files (jpg, gz, zip)NoCan't compress further
Text/code/SQL filesYesCompresses well
Slow connection (< 10 Mbps)YesMajor bandwidth savings

Commands

# Remote with compression
rsync -avz src/ user@remote:dest/

# Compression level (0=none, 9=max, default=6)
rsync -avz --compress-level=1 src/ user@remote:dest/

# Skip compression for pre-compressed files
rsync -avz --skip-compress=gz/jpg/mp4/zip/rar src/ user@remote:dest/

# Limit bandwidth to 5 MB/s
rsync -avz --bwlimit=5000 src/ user@remote:dest/

# Limit bandwidth to 1 MB/s (during business hours)
rsync -avz --bwlimit=1000 src/ user@remote:dest/

# No compression (local or LAN)
rsync -av src/ dest/

# Combine: light compression + bandwidth limit
rsync -avz --compress-level=1 --bwlimit=2000 src/ user@remote:dest/
tip

--compress-level=1 gives 80% of the bandwidth savings with 20% of the CPU cost. Best default for most remote transfers.