Posting duplicati backup events to Slack channel

This is the script’ content that worked for me:
(don’t forget to make the file executable, if on mac or linux)

#!/bin/bash

SLACK_WEBHOOK_URL=https://hooks.slack.com/services/OBFUSCATED
SLACK_CHANNEL="#backups"
SLACK_MSG="Backup performed for ${DUPLICATI__backup_name}"

curl -s -X POST --data-urlencode "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"duplicati\", \"text\": \"${SLACK_MSG}\", \"icon_emoji\": \":information_source:\"}" "${SLACK_WEBHOOK_URL}"

The only wish that I have left right now is to be able to detect whether a backup failed, so I can change how I post the message to slack (with a big exclamation if it failed). I couldn’t find an appropriate DUPLICATI__xxx environment variable for that, not from the environment variables printed, neither from source

1 Like