From 3f83b3870b9904bbb922867e2878ebc5f5641b7c Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 4 Aug 2023 17:33:42 +0200 Subject: [PATCH] syncoid: send mail on success (#567) Reviewed-on: https://git.mgrote.net/mg/homeserver/pulls/567 Co-authored-by: Michael Grote Co-committed-by: Michael Grote --- roles/mgrote.zfs_sanoid/templates/syncoid.service.j2 | 2 +- roles/mgrote.zfs_sanoid/templates/syncoid_mail.service.j2 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/mgrote.zfs_sanoid/templates/syncoid.service.j2 b/roles/mgrote.zfs_sanoid/templates/syncoid.service.j2 index fc69d41b..eda86d2a 100644 --- a/roles/mgrote.zfs_sanoid/templates/syncoid.service.j2 +++ b/roles/mgrote.zfs_sanoid/templates/syncoid.service.j2 @@ -3,7 +3,7 @@ [Unit] Description=Send zfs snapshots with sanoid/syncoid. OnFailure=syncoid_mail.service - +OnSuccess=syncoid_mail.service [Service] Type=oneshot diff --git a/roles/mgrote.zfs_sanoid/templates/syncoid_mail.service.j2 b/roles/mgrote.zfs_sanoid/templates/syncoid_mail.service.j2 index 953b3546..8b7d6ea0 100644 --- a/roles/mgrote.zfs_sanoid/templates/syncoid_mail.service.j2 +++ b/roles/mgrote.zfs_sanoid/templates/syncoid_mail.service.j2 @@ -1,8 +1,8 @@ {{ file_header | default () }} [Unit] -Description=Send a Mail in case of an error in sanoid.service. +Description=Send a Mail for sanoid service after error or success sanoid.service. [Service] Type=oneshot -ExecStart=/bin/bash -c '/bin/systemctl status syncoid.service | mail -s "[ERROR] syncoid - %H" {{ empfaenger_mail }}' +ExecStart=/bin/bash -c '/usr/bin/journalctl -u syncoid.service -n 20| mail -s "syncoid - %H" {{ empfaenger_mail }}'