mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-09-23 01:40:29 +00:00
Add Microsoft Teams notifier
This commit is contained in:
committed by
Tobias Kaupat
parent
93e76c46fe
commit
5110483351
@@ -2,6 +2,7 @@
|
||||
|
||||
lastLogfile="/var/log/backup-last.log"
|
||||
lastMailLogfile="/var/log/mail-last.log"
|
||||
lastMicrosoftTeamsLogfile="/var/log/microsoft-teams-last.log"
|
||||
|
||||
copyErrorLog() {
|
||||
cp ${lastLogfile} /var/log/backup-error-last.log
|
||||
@@ -59,6 +60,18 @@ fi
|
||||
end=`date +%s`
|
||||
echo "Finished Backup at $(date +"%Y-%m-%d %H:%M:%S") after $((end-start)) seconds"
|
||||
|
||||
if [ -n "${TEAMS_WEBHOOK_URL}" ]; then
|
||||
teamsTitle="Restic Last Backup Log"
|
||||
teamsMessage=$( cat ${lastLogfile} | sed 's/"/\"/g' | sed "s/'/\'/g" | sed ':a;N;$!ba;s/\n/\n\n/g' )
|
||||
teamsReqBody="{\"title\": \"${teamsTitle}\", \"text\": \"${teamsMessage}\" }"
|
||||
sh -c "curl -H 'Content-Type: application/json' -d '${teamsReqBody}' '${TEAMS_WEBHOOK_URL}' > ${lastMicrosoftTeamsLogfile} 2>&1"
|
||||
if [ $? == 0 ]; then
|
||||
echo "Microsoft Teams notification successfully sent."
|
||||
else
|
||||
echo "Sending Microsoft Teams notification FAILED. Check ${lastMicrosoftTeamsLogfile} for further information."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${MAILX_ARGS}" ]; then
|
||||
sh -c "mailx -v -S sendwait ${MAILX_ARGS} < ${lastLogfile} > ${lastMailLogfile} 2>&1"
|
||||
if [ $? == 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user