I stumbled across this thread after running into a btrfs csum issue, and started looking for a way to schedule a scrub of all the btrfs disks in my system. Big kudos to Constructor for the idea, Helmonder for the script, and Squid for adding the notify part. You guys got me there!
I figured I summarize what I did to save folks from bouncing around.
I basically used Helmonder's script as a starting point.
I don't have notify set up to email me, I rely only on GUI notifications, so I dropped the -m part of the notifiy
I copied the script to have one for each disk on my system (i.e. cache, disk1, disk2, etc.), making appropriate changes
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "scrub_array" -s "Scrub Cache Drive" -d "Scrub of cache drive started" -i "normal"
btrfs scrub start -Bdr /mnt/cache > /var/log/scrub_array.log
if [ $? -eq 0 ]
then
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "scrub_array" -s "Scrub Cache Drive" -d "Scrub of cache drive finished" -i "normal"
else
/usr/local/emhttp/plugins/dynamix/scripts/notify -e "scrub_array" -s "Scrub Cache Drive" -d "Error in scrub of cache drive!" -i "alert"
fi
I used crontab -e and added entries at the bottom to run each script at 10 pm starting on the 15th of every month, one disk per day.
#
# Run monthly cron jobs at 20:00 on the 15th day of the month:
00 20 15 * * /usr/local/emhttp/plugins/dynamix/scripts/scrub_cache &>/dev/null
#
# Run monthly cron jobs at 20:00 on the 16th day of the month:
00 20 16 * * /usr/local/emhttp/plugins/dynamix/scripts/scrub_disk1 &>/dev/null
...
Notifications look like: