bench notes

Moving ZFS scrubs off the first Sunday

The stock zfsutils-linux cron job scrubs every pool on the second Sunday of the month. That is also the night the offsite backup runs, so both jobs fought over the same two spinning disks and the backup kept missing its window.

What I changed

I disabled the packaged job and added a systemd timer per pool, so the big pool scrubs on the 20th and the small SSD mirror on the 5th:

# /etc/systemd/system/zfs-scrub@.timer
[Unit]
Description=Monthly scrub of %i

[Timer]
OnCalendar=*-*-20 02:30
RandomizedDelaySec=45m
Persistent=true

[Install]
WantedBy=timers.target

The matching service just runs zpool scrub -w %i. The -w flag waits for the scrub to finish, so the unit's runtime in the journal is the scrub time, which is handy for spotting a disk that is slowing down.

Result

The 4×8 TB raidz1 takes a little under nine hours. Backups now finish by 05:00 again. Next step is getting the scrub summary into the weekly mail instead of reading the journal by hand.