649c7830b0df4e0c9961a37e9ea4ce1a8c4b9efa
- Author
- Andrea Richiardi <a.richiardi.work@gmail.com>
- Committer
- Andrea Richiardi <a.richiardi.work@gmail.com>
- Date
Message
Add notification separator
The notification request is now isolated visually for better debugging.
Diff
1diff --git a/duplicity-backup.sh b/duplicity-backup.sh
2index 57e52a45d8862dfd72d9d4c08357b73818573cb1..3c69e8339630e00b2bb5c1bdd31e9c36432a55d7 100755
3--- a/duplicity-backup.sh
4+++ b/duplicity-backup.sh
5@@ -543,23 +543,33 @@ email_logfile()
6
7 send_notification()
8 {
9- NOTIFICATION_CONTENT="duplicity-backup ${BACKUP_STATUS:-"ERROR"} [${HOSTNAME}] - \`${LOGFILE}\`"
10 if [ ! -z "${NOTIFICATION_SERVICE}" ]; then
11+ echo "-----------[ Notification Request ]-----------"
12+ NOTIFICATION_CONTENT="duplicity-backup ${BACKUP_STATUS:-"ERROR"} [${HOSTNAME}] - \`${LOGFILE}\`"
13+
14 if [ "${NOTIFICATION_SERVICE}" = "slack" ]; then
15 curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"${NOTIFICATION_CONTENT}\", \"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_USERNAME}\", \"icon_emoji\": \":${SLACK_EMOJI}:\"}" "${SLACK_HOOK_URL}"
16- echo -e "Slack notification sent to channel ${SLACK_CHANNEL}"
17 elif [ "${NOTIFICATION_SERVICE}" = "ifttt" ]; then
18 curl -X POST -H 'Content-type: application/json' --data "{\"value1\": \"${NOTIFICATION_CONTENT}\", \"value2\": \"${IFTTT_VALUE2}\"}" "${IFTTT_HOOK_URL}"
19- echo -e "IFTTT notification sent to Maker channel event ${IFTTT_EVENT}"
20 elif [ "${NOTIFICATION_SERVICE}" = "pushover" ]; then
21 curl -s \
22 -F "token=${PUSHOVER_TOKEN}" \
23 -F "user=${PUSHOVER_USER}" \
24 -F "message=${NOTIFICATION_CONTENT}" \
25 https://api.pushover.net/1/messages
26+ elif [ "${NOTIFICATION_SERVICE}" = "telegram" ]; then
27+ curl -s --max-time 10 -d "chat_id=${TELEGRAM_CHATID}&disable_web_page_preview=1&text=${NOTIFICATION_CONTENT}" "https://api.telegram.org/bot${TELEGRAM_KEY}/sendMessage" >/dev/null
28+ fi
29+
30+ echo -e "\n----------------------------------------------\n"
31+
32+ if [ "${NOTIFICATION_SERVICE}" = "slack" ]; then
33+ echo -e "Slack notification sent to channel ${SLACK_CHANNEL}"
34+ elif [ "${NOTIFICATION_SERVICE}" = "ifttt" ]; then
35+ echo -e "IFTTT notification sent to Maker channel event ${IFTTT_EVENT}"
36+ elif [ "${NOTIFICATION_SERVICE}" = "pushover" ]; then
37 echo -e "Pushover notification sent"
38 elif [ "${NOTIFICATION_SERVICE}" = "telegram" ]; then
39- curl -s --max-time 10 -d "chat_id=${TELEGRAM_CHATID}&disable_web_page_preview=1&text=${NOTIFICATION_CONTENT}" "https://api.telegram.org/bot${TELEGRAM_KEY}/sendMessage" >/dev/null
40 echo -e "Telegram notification sent"
41 fi
42 fi