Automating Scrub

Developer discussions.

Automating Scrub

Postby realfolkblues12 » Sun Feb 15, 2015 3:56 pm

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.
realfolkblues12
 
Posts: 34
Joined: Thu Feb 12, 2015 10:41 pm

Re: Automating Scrub

Postby MichaelNewbery » Mon Feb 16, 2015 10:44 pm

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.
User avatar
MichaelNewbery
 
Posts: 9
Joined: Sat May 31, 2014 7:38 pm
Location: New Zealand

Re: Automating Scrub

Postby ilovezfs » Mon Feb 16, 2015 10:47 pm

I believe ZEVO included some optional plists for this, if someone feels like extracting them from the ZEVO dmg.
ilovezfs
 
Posts: 229
Joined: Thu Mar 06, 2014 7:58 am

Re: Automating Scrub

Postby ilovezfs » Tue Feb 17, 2015 10:16 pm

No, it would be the schedule. Need the entire plist.
ilovezfs
 
Posts: 229
Joined: Thu Mar 06, 2014 7:58 am

Re: Automating Scrub

Postby ilovezfs » Tue Feb 17, 2015 10:41 pm

OK here they are:
ZEVO-autopoolscrubs-and-autosnapshots.zip
(3.56 KiB) Downloaded 150 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.
ilovezfs
 
Posts: 229
Joined: Thu Mar 06, 2014 7:58 am

Re: Automating Scrub

Postby ilovezfs » Wed Feb 18, 2015 7:39 am

ilovezfs
 
Posts: 229
Joined: Thu Mar 06, 2014 7:58 am

Re: Automating Scrub

Postby ilovezfs » Wed Feb 18, 2015 7:51 am

Looks like jollyjinx also did some work in this area: autoscrub.perl
ilovezfs
 
Posts: 229
Joined: Thu Mar 06, 2014 7:58 am

Re: Automating Scrub

Postby ylluminate » Wed Jun 28, 2017 7:12 am

So have we ever gotten anywhere on auto-scrubbing? I've been thinking about setting up a weekly scrub on my volumes...
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm

Re: Automating Scrub

Postby 4ever6 » Wed Aug 09, 2017 9:35 pm

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.
4ever6
 
Posts: 6
Joined: Fri Apr 07, 2017 7:24 pm

Re: Automating Scrub

Postby ylluminate » Thu Aug 10, 2017 8:39 am

@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.
ylluminate
 
Posts: 12
Joined: Tue Apr 15, 2014 12:08 pm

Next

Return to OpenZFS on OS X Development

Who is online

Users browsing this forum: No registered users and 1 guest