On my NAS server I use Snapraid to protect against data loss and to some extent data rott. I do backups too, but only about once a month and when all the stars align. Automatically and regularly scrubbing a Snapraid array is well advised to keep that data save.

To make the best of Snapraid it is important to scrub regularly. The Snapraid term scrub means to recalculate the parity bits and compare them to the stored parity information. Usually the calculated and stored parity bits should match. If the two results differ something went wrong and data corruption could have happened. In this case Snapraid can restore the corrupted file(s) using the stored parity information. Alternatively the file can be restored from a backup (this is a friendly reminder to do a backup).

Since there is no Snapraid daemon which performs scrubbing in the background, it is necessary to regularly scrub the Snapraid array manually. Or better, to schedule regular scrubbing with cron. Since Snapraid needs to access all files in the array it may be best (easiest) to do this in root’s crontab.

$ sudo crontab -e
...
# m h dom mon dow
0 3 * * * snapraid scrub -p 15 -l /var/log/snapraid.scrub.log

That crontab entry will make sure 15 percent of the Snapraid array are scrubbed each day at 3 am and a log file is written to keep a journal of important events. Within one week the complete Snapraid array will be scrubbed once (7 days * 15% per day = 105%).

While at it, also make sure to sync the array regularly as well.

$ sudo crontab -e
...
# m h dom mon dow
0 3 * * * snapraid scrub -p 15 -l /var/log/snapraid.scrub.log
0 6 * * 1 snapraid sync -l /var/log/snapraid.sync.log

The additional line will perform a Snapraid sync every Monday at 6 am.
These are just some values I consider reasonable for my system. If the data in the array changes a lot the intervals should be tightened. If the data changes very rarelt, as for my NAS, the intervals can be more relaxed.

This is probably the minimum effort that should be put into keeping a Snapraid array clean and up-to-date.

That’s it.


References:

  1. https://www.snapraid.it/manual