rsync --checksum vs mtime: How rsync Skips Files
By default rsync skips files whose size and modification time match; -c / --checksum compares file contents instead, at a CPU cost.
CI builds often reset mtimes, which can fool the default quick-check. Knowing when to use --checksum keeps incremental deploys correct.
What it does
rsync's default "quick check" transfers a file only if its size or modification time differs from the destination. --checksum / -c instead computes a checksum of every file on both sides and transfers when contents differ, ignoring size+mtime as the trigger. Checksum is slower (it reads every byte) but immune to mtime tricks.
Common usage
# Default quick check (size + mtime)
rsync -av dist/ user@host:/var/www/app/
# Force content comparison
rsync -avc dist/ user@host:/var/www/app/
# Force re-send everything regardless of state
rsync -av --ignore-times dist/ user@host:/srv/Comparison modes
| Flag | Decides to transfer when |
|---|---|
| (default) | Size differs OR mtime differs |
| -c / --checksum | Content checksum differs |
| --size-only | Size differs (ignore mtime) |
| -I / --ignore-times | Always transfer (skip the quick check) |
| --ignore-existing | Only create files missing on destination |
In CI
If your build regenerates files with the same content but new mtimes (common with bundlers), the default check re-uploads unchanged files every deploy. Use --checksum so only real content changes transfer, or normalize mtimes. If a build keeps the same mtime but changes content (rare), the default would wrongly skip it; --checksum catches that too.
Common errors in CI
There is no error, but a misleading "no changes" or "everything re-uploaded" symptom usually traces back to mtime handling. --size-only is tempting but unsafe: a file edited without changing size is skipped. Prefer --checksum when correctness matters.