Homelab

restic check reads a twentieth of the backups every Saturday

Since the backup incident the weekly check reads part of the stored data back and compares it with its checksums. Twenty Saturdays read all of it.

0:00
/0:06
The first run on the NAS, reading 5 % of the packs. The clip loops.

Every Saturday at 07:00 the NAS runs restic check --read-data-subset, which reads part of the stored data back and compares it with its checksums. Until last week my weekly check was a look at restic snapshots. That shows a snapshot exists, and says nothing about whether it can be restored.

Five percent, or one part in twenty

The clip shows the first run, with 5%. That picks packs at random, so some are read twice before others are read at all. n/20 reads the n-th of twenty fixed parts instead, and with the week number as n, twenty Saturdays read every pack once.

#!/usr/bin/env bash
set -euo pipefail

part=$(( 10#$(date +%V) % 20 + 1 ))
restic -r /srv/restic check --read-data-subset "${part}/20"

10# keeps bash from reading week 08 as an octal number. It takes 14 minutes on the NAS, at an hour when nothing else runs.

Comments

Buy Logbuch