From de7a6be9fec2944d85be81e21c30aec734bff7a7 Mon Sep 17 00:00:00 2001 From: Gerard Ribas Canals Date: Fri, 13 Oct 2017 10:17:01 +0200 Subject: [PATCH 1/2] Telegram Notifications --- duplicity-backup.conf.example | 4 ++++ duplicity-backup.sh | 3 +++ 2 files changed, 7 insertions(+) diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example index 0a0dc99..0391982 100644 --- a/duplicity-backup.conf.example +++ b/duplicity-backup.conf.example @@ -439,6 +439,10 @@ IFTTT_MAKER_EVENT="duplicity" # name the event to trigger at IFTTT Maker Channel IFTTT_HOOK_URL="https://maker.ifttt.com/trigger/$IFTTT_MAKER_EVENT/with/key/$IFTTT_KEY" # ONLY change this if IFTTT changes it IFTTT_VALUE2="" # general purpose value to pass to your maker channel (optional) +# Provider: Telegram +TELEGRAM_CHATID="" #Generate a Telegram bot following guide: https://core.telegram.org/bots#3-how-do-i-create-a-bot +TELEGRAM_KEY="" + # ------------------------------------------------------------------------------ # TROUBLESHOOTING # ------------------------------------------------------------------------------ diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 739fab3..ee4c6a8 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -569,6 +569,9 @@ send_notification() -F "message=${NOTIFICATION_CONTENT}" \ https://api.pushover.net/1/messages echo -e "Pushover notification sent" + elif [ "${NOTIFICATION_SERVICE}" = "telegram" ]; then + 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 + echo -e "Telegram notification sent" fi fi } From a7752c4c78b98c0223542ba3a370c735bf269807 Mon Sep 17 00:00:00 2001 From: zertrin Date: Mon, 30 Oct 2017 23:34:45 +0800 Subject: [PATCH 2/2] Minor changes before merging PR adding Telegram notifications support --- duplicity-backup.conf.example | 2 +- duplicity-backup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/duplicity-backup.conf.example b/duplicity-backup.conf.example index 0391982..50b1b6a 100644 --- a/duplicity-backup.conf.example +++ b/duplicity-backup.conf.example @@ -419,7 +419,7 @@ MAIL="mailx" # default command for Linux mail # Third-party notification services. If NOTIFICATION_SERVICE is not provided, no # notifications will be sent. -# Possible values for NOTIFICATION_SERVICE are: slack, pushover, ifttt +# Possible values for NOTIFICATION_SERVICE are: slack, pushover, ifttt, telegram NOTIFICATION_SERVICE="" NOTIFICATION_FAILURE_ONLY="yes" # send notifications only if there was an error while creating backup diff --git a/duplicity-backup.sh b/duplicity-backup.sh index 8b2f0f1..8642d59 100755 --- a/duplicity-backup.sh +++ b/duplicity-backup.sh @@ -559,7 +559,7 @@ send_notification() https://api.pushover.net/1/messages echo -e "Pushover notification sent" elif [ "${NOTIFICATION_SERVICE}" = "telegram" ]; then - 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 + 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 echo -e "Telegram notification sent" fi fi