Skip to content

Instantly share code, notes, and snippets.

@Preclowski
Last active January 20, 2026 21:20
Show Gist options
  • Select an option

  • Save Preclowski/21039706faadfbde27730c85279abf0d to your computer and use it in GitHub Desktop.

Select an option

Save Preclowski/21039706faadfbde27730c85279abf0d to your computer and use it in GitHub Desktop.
Snapraid sync systemd task with spinning down parity drive and ntfy notification
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`
[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'
[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"
[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