Last active
January 20, 2026 21:20
-
-
Save Preclowski/21039706faadfbde27730c85279abf0d to your computer and use it in GitHub Desktop.
Snapraid sync systemd task with spinning down parity drive and ntfy notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Should work just fine on Debian/Ubuntu, at least | |
| 1. Put `.service` and `.timer` in `/etc/systemd/system` | |
| 2. `sudo systemctl enable snapraid-sync.timer` | |
| 3. To verify (run once) `sudo systemctl start snapraid-sync.service` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=Send a ntfy notification for service %i | |
| [Service] | |
| Type=oneshot | |
| Environment=NTFY_URL=https://ntfy.sh | |
| Environment=NTFY_TOPIC=system | |
| Environment=NTFY_TAGS=info | |
| Environment=NTFY_MESSAGE= | |
| ExecStart=/bin/sh -c '/usr/bin/curl -s \ | |
| -H "Title: %i on %H" \ | |
| -H "Tags: $NTFY_TAGS" \ | |
| -H "Firebase: no" \ | |
| -d "${NTFY_MESSAGE:-Notification from service %i on %H}" \ | |
| $NTFY_URL/$NTFY_TOPIC' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=SnapRAID weekly sync | |
| RequiresMountsFor=/srv/storage/sata01 \ | |
| /srv/storage/... \ | |
| /srv/storage/sata16 | |
| OnFailure=ntfy-notification@%n.service | |
| [Service] | |
| Type=oneshot | |
| # Prevent system from sleep/shutdown during sync | |
| ExecStart=systemd-inhibit --what="idle:sleep:shutdown" --who="snapraid" --why="Performing disks sync" /usr/bin/snapraid sync | |
| # Wait 30s before unounting parity drive | |
| ExecStartPost=/bin/sleep 30 | |
| # Unmount drive | |
| ExecStopPost=/usr/bin/hdparm -Y /dev/disk/by-uuid/xxxx-xxxx-xxxx-xxxx-xxxx | |
| Environment=NTFY_TAGS=triangular_flag_on_post | |
| Environment=NTFY_TOPIC=storage | |
| Environment=NTFY_MESSAGE="Something went wrong during weekly SnapRAID sync" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=Timer for SnapRAID weekly sync | |
| [Timer] | |
| OnCalendar=Sun *-*-* 04:20:00 | |
| Persistent=true | |
| [Install] | |
| WantedBy=timers.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment