brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: restic check --read-data-subset=10% reads a slice of your backup to prove it is intact

Backup
~/tips/tip-backup-restic-check-read-data-subset

restic -r /srv/restic-repo check --read-data-subset=10%

Verifies a random or numbered slice of your restic repository by reading the actual data files.

Nobody can say a backup works until it has been read back. The plain restic check looks at the repository structure, but it does not open the pack files that hold your data. The --read-data-subset option does, and you decide how much of the repository it reads.

Here is the percentage form, which checks a randomly chosen part of the pack files:

restic -r /srv/restic-repo check --read-data-subset=10%

You can also give a size, such as 50M or 10G, and restic converts it to a percentage of the repository. If you would rather cover everything over time, split the repository into parts. With n/t you check part n of t, so five runs cover the whole repository:

restic -r /srv/restic-repo check --read-data-subset=1/5
restic -r /srv/restic-repo check --read-data-subset=2/5
# ... up to 5/5

That makes a nice schedule: one fifth on each night of a work week, and you have read every pack file once. The restic docs say that random percentages do not guarantee full coverage even after many runs, but they are easy to automate. For larger percentages the docs advise writing an integer, so 10% rather than something fractional like 2.5.

The caveat is cost. The full --read-data flag has to download every pack file, which the docs warn can mean higher bandwidth costs and much more time than a normal check. With a repository on a cloud bucket, those downloads can show up on a bill, so a small subset on a regular schedule is the friendlier choice. A local repository on a second disk has no such problem, and I would read all of it now and then.

Also keep in mind what a check proves. It tells you the stored data is intact. It cannot tell you whether you backed up the right folders. A restore test of one file from time to time covers that gap.

Further reading: restic docs: Working with repositories (check)

More Backup tips restic snapshots --group-by host,paths mysqldump --routines --events mydb > mydb.sql rsync -a --files-from=list.txt /home/me/ backup:/backup/ restic find "*.txt" restic stats All Backup tips (45) All topics

Link