By default, rsync treats regular files with matching sizes and modification times as unchanged. That quick check suits routine transfers, but it can miss content drift after a restore, migration, or storage fault preserves both pieces of metadata.
The --checksum option makes rsync read candidate files on both sides and compare whole-file checksums. Combining it with --dry-run and --itemize-changes reports content differences without changing the destination.
Checksum comparison reads file data that the normal quick check can skip, so large trees take longer and generate more disk activity. Limit the audit to the copy, restore, or suspicious path that needs content-level verification.
Steps to compare files by checksum with rsync:
- Run a normal dry run against the paths being audited.
$ rsync -a --dry-run --itemize-changes /srv/fixture/source/ /srv/fixture/destination/
No output means the normal size-and-modification-time check found no differences for the selected paths and options.
- Repeat the dry run with checksum comparison enabled.
$ rsync -a --checksum --dry-run --itemize-changes /srv/fixture/source/ /srv/fixture/destination/ >fc........ reports/summary.txt
The first character, >, means the file would be sent to the destination. The f identifies a regular file, and c marks a file-content checksum difference. --dry-run leaves the destination unchanged.
- Confirm a reported file with an independent hash command.
$ sha256sum /srv/fixture/source/reports/summary.txt /srv/fixture/destination/reports/summary.txt 8ed3f6ad685b959ead7022518e1af76cd816f8e8ec7ccdda1ed4018e8f2223f8 /srv/fixture/source/reports/summary.txt f144a6907dc4284d1f9fe6a7d9b9ff53c02c1d07ba68f24d413d7ff7f757a782 /srv/fixture/destination/reports/summary.txt
Different SHA-256 values confirm that the contents differ. Investigate the source of the drift before using a separate copy or mirror command to change either tree.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.