Compression & Bandwidth
When to Compress
| Scenario | Use -z? | Why |
|---|---|---|
| Remote server (WAN) | Yes | Saves bandwidth |
| Local transfer | No | CPU overhead, no benefit |
| LAN (1 Gbps+) | No | Network faster than CPU |
| Already compressed files (jpg, gz, zip) | No | Can't compress further |
| Text/code/SQL files | Yes | Compresses well |
| Slow connection (< 10 Mbps) | Yes | Major 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.