Check data for bitrot
Bitrot is data that changes on disk without anyone writing it: a flipped
bit, a bad sector, a faulty controller. The file’s size and modification time
stay the same, so most tools do not notice. fileset reads every byte again
and compares it with the checksum it recorded.
The examples use ~/Photos. Every option is in the reference.
Record, then check later
Record a manifest while you know the data is good:
fileset init ~/Photos
Months later, run check. No copy is involved:
fileset check ~/Photos
A file whose bytes changed while its size and modification time stayed the
same shows up as a CHG line with blake3 alone:
CHG 2026/01/IMG_0001.jpg blake3=81c4b7f7e0549f1514e9cae97cf40cf133920418d3dc71bedbf60ec9bd6148cb→7d271ea55b6b5af8d6a863e4530228f65ffc4a33086a485d73e84ee84243463f
fileset reports; it repairs nothing. Restore the file from another copy,
and check that copy first so that you do not spread the damage.
Rot or an edit?
Rot usually shows as a CHG line with blake3 alone, while an edit changes
the time and size too. Check before you update
explains how to tell them apart and why the order matters.
Check on a schedule
check exits 0 when clean, 1 when it found differences and 2 when the run
itself failed. A cron job can use that. This line checks at 03:00 on the first of each
month. It writes everything to a log, and prints a message, which cron mails
to its owner, only when the check did not exit 0:
0 3 1 * * $HOME/.cargo/bin/fileset check -q $HOME/Photos > $HOME/fileset-check.log 2>&1 || echo "fileset check exited with $?; see $HOME/fileset-check.log"
Cron has a short PATH that does not include ~/.cargo/bin, so the line
gives the full path to fileset. Cron runs the command with sh, which
expands $HOME; it does not expand ~ everywhere, for example not in PATH=
lines, so write $HOME or the full path. The mail only arrives if local mail
is set up on the machine.
-q hides progress. The summary line still goes to stderr, which is why the
log takes both streams. Add --fail-on-warnings when an unreadable file
should count as a failure too. Warnings alone give exit 0 otherwise.
Exit 1 and exit 2 are different problems. Exit 1 means your data differs from
the manifest. Exit 2 means fileset could not run, for example because the
disk is not mounted or the manifest is missing.
Read-only media and snapshots
check never changes the tree. But a manifest inside a read-only tree may
fail to open, with exit 2 and a message suggesting --manifest. Copy the
manifest somewhere writable and point --manifest at the copy:
cp /mnt/snapshot/photos/.fileset.sqlite /tmp/photos.fileset.sqlite
fileset check --manifest /tmp/photos.fileset.sqlite /mnt/snapshot/photos
If you know the tree will end up on such media, create its manifest with
fileset init --store redb. That manifest is a single file that check
only reads, so it needs no copy. See
The redb backend.