Page 1 of 2

Automating Scrub

PostPosted: Sun Feb 15, 2015 3:56 pm
by realfolkblues12
Hello I was wondering if their are any scripts out their to automate scrubbing already? If not i'll be writing my own and be happy to post it once done.

Re: Automating Scrub

PostPosted: Mon Feb 16, 2015 10:44 pm
by MichaelNewbery
Since I only have one pool, I use the following script.
Code: Select all
#!/bin/sh -

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

weekly_zfs_enable="YES"

case "$weekly_zfs_enable" in
    [Yy][Ee][Ss])
        echo ""
        echo "Scrubing zpool POOLNAME:"

      zpool scrub POOLNAME

    *)  rc=0;;
esac

exit $rc

Note that you need to change POOLNAME to the name of your pool.

This is placed somewhere useful (/Server/periodic/weekly/100.zfs in my case) and then made to run once a week via launchctl using the following file.
/Library/LaunchDaemons/local.periodic-weekly.plist
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>local.periodic-weekly</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/sbin/periodic</string>
                <string>/Server/periodic/weekly</string>
        </array>
        <key>QueueDirectories</key>
        <array/>
        <key>StartCalendarInterval</key>
        <dict>
                <key>Hour</key>
                <integer>2</integer>
                <key>Minute</key>
                <integer>15</integer>
                <key>Weekday</key>
                <integer>0</integer>
        </dict>
        <key>WatchPaths</key>
        <array/>
</dict>
</plist>


This is simplistic, but may be useful to you.

Re: Automating Scrub

PostPosted: Mon Feb 16, 2015 10:47 pm
by ilovezfs
I believe ZEVO included some optional plists for this, if someone feels like extracting them from the ZEVO dmg.

Re: Automating Scrub

PostPosted: Tue Feb 17, 2015 10:16 pm
by ilovezfs
No, it would be the schedule. Need the entire plist.

Re: Automating Scrub

PostPosted: Tue Feb 17, 2015 10:41 pm
by ilovezfs
OK here they are:
ZEVO-autopoolscrubs-and-autosnapshots.zip
(3.56 KiB) Downloaded 671 times

So the key is the StartInterval.

The ZEVO custom "automatic" argument might have meant do all pools. Running "zpool scrub automatic" might make it evident whether that's what it meant, assuming multiple pools are imported.

Re: Automating Scrub

PostPosted: Wed Feb 18, 2015 7:39 am
by ilovezfs

Re: Automating Scrub

PostPosted: Wed Feb 18, 2015 7:51 am
by ilovezfs
Looks like jollyjinx also did some work in this area: autoscrub.perl

Re: Automating Scrub

PostPosted: Wed Jun 28, 2017 7:12 am
by ylluminate
So have we ever gotten anywhere on auto-scrubbing? I've been thinking about setting up a weekly scrub on my volumes...

Re: Automating Scrub

PostPosted: Wed Aug 09, 2017 9:35 pm
by 4ever6
ylluminate wrote:So have we ever gotten anywhere on auto-scrubbing? I've been thinking about setting up a weekly scrub on my volumes...


I'm trying to understand why this seems like something that needs to be done.

Re: Automating Scrub

PostPosted: Thu Aug 10, 2017 8:39 am
by ylluminate
@4ever6 to me, it is useful to show a regularly updated status of the integrity of my volumes and data. I would like to see this in an automated fashion so as to not have to realize after some months "Oooops, I forgot to check my drives / data and now I have some risk of losing some data because I have 2 drives going bad" or such. Automated checking and reminders is pretty important in my mind.