Do we want a periodic script for a zfs scrub?

Artem Belevich fbsdlist at src.cx
Thu Jun 10 14:59:55 UTC 2010


> Good idea! I even found a command line which does the calculation for the
> number of days between "now" and the last run (not taking a leap year into
> account, but an off-by-one day error here does not matter).

You can get exactly one month difference by using -v option of 'date'
command to figure out the time/date offset by arbitrary amount.
Combined with +"%s" format to print number of seconds since Epoch and
-r to specify the reference point in time it makes 'date' pretty
useful in scripts.

--Artem



On Thu, Jun 10, 2010 at 2:53 AM, Alexander Leidinger
<Alexander at leidinger.net> wrote:
> Quoting jhell <jhell at dataix.net> (from Wed, 09 Jun 2010 11:23:10 -0400):
>
>> On 06/09/2010 11:07, jhell wrote:
>>>
>>> On 06/09/2010 10:26, Alexander Leidinger wrote:
>>>>
>>>> Hi,
>>>>
>>>> I noticed that we do not have an automatism to scrub a ZFS pool
>>>> periodically. Is there interest in something like this, or shall I keep
>>>> it local?
>>>>
>>>> Here's the main part of the monthly periodic script I quickly created:
>>>> ---snip---
>>>> case "$monthly_scrub_zfs_enable" in
>>>>    [Yy][Ee][Ss])
>>>>        echo
>>>>        echo 'Scrubbing of zfs pools:'
>>>>
>>>>        if [ -z "${monthly_scrub_zfs_pools}" ]; then
>>>>                monthly_scrub_zfs_pools="$(zpool list -H -o name)"
>>>>        fi
>>>>
>>>>        for pool in ${monthly_scrub_zfs_pools}; do
>>>>                # successful only if there is at least one pool to scrub
>>>>                rc=0
>>>>
>>>>                echo "   starting scrubbing of pool '${pool}'"
>>>>                zpool scrub ${pool}
>>>>                echo "      consult 'zpool status ${pool}' for the
>>>> result"
>>>>                echo "      or wait for the daily_status_zfs mail, if
>>>> enabled"
>>>>        done
>>>>        ;;
>>>> ---snip---
>>>>
>>>> Bye,
>>>> Alexander.
>>>>
>>>
>>> Please add a check to see if any resilerving is being done on the pool
>>> that the scub is being executed on. (Just in case), I would hope that
>>> the scrub would fail silently in this case.
>>>
>>> Please also check whether a scrub is already running on one of the pools
>>> and if so & another pool exists start a background loop to wait for the
>>> first scrub to finish or die silently.
>>>
>>> I had a scrub fully restart from calling scrub a second time after being
>>> more than 50% complete, its frustrating.
>>>
>>>
>>> Thanks!,
>>>
>>
>> I should probably suggest one check that comes to mind.
>>
>> zpool history ${pool} | grep scrub | tail -1 |cut -f1 -d.
>>
>> Then compare the output with today's date to make sure today is >= 30
>> days from the date of the last scrub.
>>
>> With the above this could be turned into a daily_zfs_scrub_enable with a
>> default daily_zfs_scrub_threshold="30" and ensuring that if one check is
>> missed it will not take another 30 days to run the check again.
>
> Good idea! I even found a command line which does the calculation for the
> number of days between "now" and the last run (not taking a leap year into
> account, but an off-by-one day error here does not matter).
>
> Bye,
> Alexander.
>
> --
> "He's a businessman. I'll make him an offer he can't refuse."
>                -- Vito Corleone, "Chapter 1", page 39
>
> http://www.Leidinger.net    Alexander @ Leidinger.net: PGP ID = B0063FE7
> http://www.FreeBSD.org       netchild @ FreeBSD.org  : PGP ID = 72077137
> _______________________________________________
> freebsd-fs at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-fs
> To unsubscribe, send any mail to "freebsd-fs-unsubscribe at freebsd.org"
>


More information about the freebsd-fs mailing list