This repository has been archived on 2025-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
pyinfra-lxd/files/zfs-scrub.sh_clear

19 lines
503 B
Text
Raw Normal View History

2021-02-06 17:03:07 +09:00
#!/usr/bin/env bash
# https://serverfault.com/questions/538978/how-to-run-a-command-once-a-zfs-scrub-completes
set -euo pipefail
curl -m 10 --retry 5 <healthchecks_url>/start
2021-02-06 17:03:07 +09:00
zpool scrub local
# wait until scrub is finished
while zpool status local | grep -q 'scan: *scrub in progress'; do
zpool status local
sleep 600
done
zpool status local
# Get stdout from journalctl
2021-02-06 18:07:57 +09:00
LOG=$(journalctl -o cat -u zfs-scrub.service -n 100)
curl -fsS -m 10 --retry 5 --data-raw "$LOG" <healthchecks_url>
2021-02-06 17:03:07 +09:00
exit 0