Checking local files integrity agains repo

My NAS just complained that the filesystem was unclean and it did a filesystem check. Now I want to know if some files might be broken. I have the NAS backed up with restic. Is it posible to compare checksums or something with the latest snapshot in my restic repo to identify possible broken files?

The following procedure may vary a bit from system to system, and there are lots of opportunities to optimize it (see xargs!), but hopefully it conveys the basic steps to you.

  1. Mount your restic respository. restic -r /path/to/repository mount /mnt/restic &
  2. Change directories into the latest snapshot. cd /mnt/restic/snapshots/latest
  3. Create a sha256sum checkfile. find . -type f -exec sha256sum {} \; | tee /tmp/checklist.
  4. Change directory out of the restic repository into the topmost directory where your backup begins. cd /
  5. Unmount the restic repository. umount /mnt/restic
  6. Check all SHA file hashes from the repo with your live filesystem. sha256sum -c /tmp/checklist

While @David 's solution works well, note that it needs to download all data from your repository to locally compute the SHA256 hashes of each file backup’ed. If your repository is remote this may take a long time and may be expensive.

An alternative would be to simply run backup --force (which re-reads, re-chunks and re-hashes every file) and then restic diff to compare the newly generated snapshot with any of the already existing snapshots. This only needs to read local files. However, it saves extra data in the repository if your local files are changed (e.g. corrupted).

1 Like

Thanks, it’s about 20TB in the cloud so I think this is the route Ill take. I can always delete the snapshot afterwards.