f4c999b2c5bbae40096e1d14cc695e66171e4814

Author
zertrin <zrk951@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

Merge pull request #133 from jrbenito/ifttt

Add IFTTT notification service

Diff

 1diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example
 2index 6911eec7fc1f98a7b4f285baca02741e92bf6375..c2bfaa21ea3629d85f200e2b860ddea2e71be9b4 100644
 3--- a/duplicity-backup.conf.example
 4+++ b/duplicity-backup.conf.example
 5@@ -408,7 +408,7 @@ MAIL="mailx"     # default command for Linux mail
 6 # Third-party notification services. If NOTIFICATION_SERVICE is not provided, no
 7 # notifications will be sent.
 8 
 9-# Possible values for NOTIFICATION_SERVICE are: slack, pushover
10+# Possible values for NOTIFICATION_SERVICE are: slack, pushover, ifttt
11 NOTIFICATION_SERVICE=""
12 NOTIFICATION_FAILURE_ONLY="yes" # send notifications only if there was an error while creating backup
13 
14@@ -422,6 +422,11 @@ SLACK_EMOJI="package"
15 PUSHOVER_TOKEN="" # App token generated at pushover.net
16 PUSHOVER_USER="" # User key from pushover.net
17 
18+# Provider: IFTTT
19+IFTTT_KEY="" # Key for MAKER channel at IFTTT
20+IFTTT_MAKER_EVENT="duplicity" # name the event to trigger at IFTTT Maker Channel
21+IFTTT_HOOK_URL="https://maker.ifttt.com/trigger/$IFTTT_MAKER_EVENT/with/key/$IFTTT_KEY" # ONLY change this if IFTTT changes it
22+IFTTT_VALUE2="" # general purpose value to pass to your maker channel (optional)
23 
24 # ------------------------------------------------------------------------------
25 # TROUBLESHOOTING
26diff --git a/duplicity-backup.sh b/duplicity-backup.sh
27index a1a72fa9845c0e2c5a886c5749223ec4f04c9aa1..c911657c2c7176ddb29228fc1188fe7237f8302e 100755
28--- a/duplicity-backup.sh
29+++ b/duplicity-backup.sh
30@@ -416,6 +416,9 @@ send_notification()
31     if [ "${NOTIFICATION_SERVICE}" = "slack" ]; then
32       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}"
33       echo -e "Slack notification sent to channel ${SLACK_CHANNEL}" >> "${LOGFILE}"
34+    elif [ "${NOTIFICATION_SERVICE}" = "ifttt" ]; then
35+      curl -X POST -H 'Content-type: application/json' --data "{\"value1\": \"${NOTIFICATION_CONTENT}\", \"value2\": \"${IFTTT_VALUE2}\"}" "${IFTTT_HOOK_URL}"
36+      echo -e "IFTTT notification sent to Maker channel event ${IFTTT_EVENT}" >> "${LOGFILE}"	
37     elif [ "${NOTIFICATION_SERVICE}" = "pushover" ]; then
38       curl -s \
39       -F "token=${PUSHOVER_TOKEN}" \