envoi mail après backup
This commit is contained in:
parent
0f0eedc57b
commit
c0cdb3e29d
@ -23,15 +23,21 @@ let
|
||||
!AUTH_OK !API
|
||||
'';
|
||||
|
||||
sendMail = to: subject: message: pkgs.writeShellScriptBin "mail.sh" ''
|
||||
${pkgs.system-sendmail}/bin/sendmail ${to} <<EOF
|
||||
From: root@nyanlout.re
|
||||
Subject: ${subject}
|
||||
${message}
|
||||
EOF
|
||||
'';
|
||||
|
||||
login_mail_alert = pkgs.writeShellScriptBin "mail_alert.sh" ''
|
||||
if [ "$PAM_TYPE" != "close_session" ]; then
|
||||
${pkgs.system-sendmail}/bin/sendmail paul@nyanlout.re <<EOF
|
||||
From: root@nyanlout.re
|
||||
Subject: SSH Login: $PAM_USER from $PAM_RHOST
|
||||
`env`
|
||||
EOF
|
||||
${sendMail "paul@nyanlout.re" "SSH Login: $PAM_USER from $PAM_RHOST" "`env`"}
|
||||
fi
|
||||
'';
|
||||
|
||||
backup_mail_alert = sendMail "paul@nyanlout.re" "ERREUR: Sauvegarde Borg" "Impossible de terminer la sauvegarde. Merci de voir les logs";
|
||||
in
|
||||
|
||||
{
|
||||
@ -348,6 +354,8 @@ in
|
||||
${pkgs.zfs}/bin/zfs destroy loutrepool/var/postgresql@borgsnap
|
||||
if [[ $exitStatus == 0 ]]; then
|
||||
${pkgs.rclone}/bin/rclone --config /mnt/secrets/rclone_loutre.conf sync -v $BORG_REPO BackupStorage:loutre
|
||||
else
|
||||
${backup_mail_alert}/bin/mail.sh
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user