Error-Mail wenn restic-backup einen Exit-Code !=0 hat (#5)

Link

Typo

Bugfix: Postfix - tlx-param

Mailversand - wip

Syntax

Rolle postfix als Voraussetzung für restic

Co-authored-by: Michael Grote <38253905+quotengrote@users.noreply.github.com>
Reviewed-on: mg/ansible#5
This commit is contained in:
Michael Grote 2020-12-18 22:07:03 +01:00
parent 2a78a95724
commit ffe99130f9
3 changed files with 11 additions and 2 deletions

View file

@ -7,7 +7,7 @@
gmail_mail_nach_cronjob: false gmail_mail_nach_cronjob: false
gmail_smtp_server: smtp.gmail.com gmail_smtp_server: smtp.gmail.com
gmail_smtp_server_port: 587 gmail_smtp_server_port: 587
gmail_smtp_use_tls: yes gmail_smtp_use_tls: "yes"
### mgrote.set_apt_sources ### mgrote.set_apt_sources
acng_server: acng.grote.lan acng_server: acng.grote.lan
acng_server_port: 9999 acng_server_port: 9999

View file

@ -0,0 +1,3 @@
---
dependencies:
- role: mgrote.postfix-gmail

View file

@ -19,12 +19,18 @@ function unlock() {
# Damit prueft ob das Script ob es schon laeuft # Damit prueft ob das Script ob es schon laeuft
exlock exlock
( (
echo "--------------------------------------------------" echo "--------------------------------------------------"
echo $(date) echo $(date)
mount -t cifs -o credentials="/etc/restic/smb_password.txt",vers=3.0 {{ restic_repository }} {{ restic_mount }} mount -t cifs -o credentials="/etc/restic/smb_password.txt",vers=3.0 {{ restic_repository }} {{ restic_mount }}
restic -r {{ restic_mount }} --password-file /etc/restic/password.txt backup --exclude-file /etc/restic/exclude.txt {{ restic_folders_to_backup }} restic -r {{ restic_mount }} --password-file /etc/restic/password.txt backup --exclude-file /etc/restic/exclude.txt {{ restic_folders_to_backup }}
# Mail wenn Restix Exit != 0 #https://stackoverflow.com/a/45817972
retVal=$?
if [ $retVal -ne 0 ]; then
echo "ERROR - Restic - $HOSTNAME" | mail -s "ERROR - Restic - $HOSTNAME" {{ empfaenger_mail }}
fi
umount {{ restic_mount }} umount {{ restic_mount }}
echo "--------------------------------------------------" echo "--------------------------------------------------"