4 ms·
Once a month is fine ("/etc/cron.monthly/zfs-scrub"): #!/bin/bash # # ZFS scrub script for monthly maintenance # Place in /etc/cron.monthly/zfs
by atmosx 9mo ago
Once a month is fine ("/etc/cron.monthly/zfs-scrub"):
#!/bin/bash
#
# ZFS scrub script for monthly maintenance
# Place in /etc/cron.monthly/zfs-scrub
POOL="storage"
TAG="zfs-scrub"
# Log start
logger -t "$TAG" -p user.notice "Starting ZFS scrub on pool: $POOL"
# Run the scrub
if /sbin/zpool scrub "$POOL"; then
logger -t "$TAG" -p user.notice "ZFS scrub initiated successfully on pool: $POOL"
else
logger -t "$TAG" -p user.err "Failed to start ZFS scrub on pool: $POOL"
exit 1
fi
exit 0
- chungy 9mo agoThat script might do with the "-w" parameter passed to scrub. Then "zpool scrub" won't return until the scrub is finished.
- k_bx 9mo agoDidn't know about the logger script, looks nice. Can it wrap the launch of the scrub itself so that it logs like logger too, or do you separately track its stdout/stderr when something happens? update: figured how you can improve that call to add logs to logger
- nubinetwork 9mo agoScrub doesn't log anything by default, you run it and it returns quickly... you have to get the results out of zpool status or through zed.
- atmosx 9mo agoThe status of the pool is tracked by Prometheus though an ZFS exporter and faults are reported via alert manager & pushover.