# Posting duplicati backup events to Slack channel

**URL:** <https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931>\
**Category:** Uncategorized\
**Created:** [October 7, 2017, 7:01am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931 "2017-10-07T07:01:02Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomname872634](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@randomname872634](https://forum.duplicati.com/u/randomname872634)\
**Post date:** [October 7, 2017, 7:01am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/1 "2017-10-07T07:01:02Z")

</div>

First off, I really enjoy duplicati. It’s a great project that has already spared me a lot of time building my own custom backup solution (for backing up to Google Drive).

I was wondering if anyone has managed to get posting messages to Slack working. I’d like to report to Slack if a backup was run (the backup name) and the outcome (succes/fail). I think I have to use the global options ‘send-http-url’ and ‘send-http-any-operation’, but have not really found how to add useful parameters to the message.

So, before re-inventing the wheel, has anyone else done this (or something alike) and/or can point me to some examples and/or can point me to some documentation?

---

<div class="post-metadata">

**Author:** ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)\
**Post date:** [October 7, 2017, 2:53pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/2 "2017-10-07T14:53:49Z")

</div>

I’m not familiar with Slack, but assuming it’s got a CLI available for it you could probably use the ‘run-script-after’ feature.

Various info about the competed job should be available in ‘duplicati\_\_XXXX’ style environment variables (note the 2 underscores).

It’s a bit more “hackey” than an http API but is better than nothing. 🙂

---

<div class="post-metadata">

**Author:** ![randomname872634](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@randomname872634](https://forum.duplicati.com/u/randomname872634)\
**Post date:** [October 7, 2017, 6:31pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/3 "2017-10-07T18:31:53Z")

</div>

Thank you for your quick reply.

I’ll give the run-script-after feature a try, using curl under the hoods (Slack has a very decent HTTP API).  
Knowing the environment variables pattern helps me.

---

<div class="post-metadata">

**Author:** ![randomname872634](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@randomname872634](https://forum.duplicati.com/u/randomname872634)\
**Post date:** [October 7, 2017, 8:09pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/4 "2017-10-07T20:09:25Z")

</div>

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](https://searchcode.com/codesearch/view/25021533/)

---

<div class="post-metadata">

**Author:** ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)\
**Post date:** [October 7, 2017, 9:39pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/5 "2017-10-07T21:39:38Z")

</div>

That was fast - well done!

This list from another topic might help…

> [@"run-script-after" only if backup finished - how?](https://forum.duplicati.com/t/run-script-after-only-if-backup-finished-how/764/2):
>
> There are also some special non-option vairables that are probably what you’re intersted in:
> 
> DUPLICATI\_\_EVENTNAME = when script was triggered such as “BEFORE” or “AFTER”  
> DUPLICATI\_\_OPERATIONNAME = operation, such as “Backup”, “Cleanup”, “Restore”, etc.  
> DUPLICATI\_\_RESULTFILE = path to file in which result data is stored  
> DUPLICATI\_\_REMOTEURL = “URL” target backend  
> DUPLICATI\_\_LOCALPATH = path to folders being backed up or restored  
> DUPLICATI\_\_PARSED\_RESULT = run result such as “Unknown”, “Success”, “Warning”, “Error”, or “Fatal”

Edit: Removed scripting code that somehow got in there with a copy paste (sorry about that).

---

<div class="post-metadata">

**Author:** ![randomname872634](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@randomname872634](https://forum.duplicati.com/u/randomname872634)\
**Post date:** [October 8, 2017, 7:08am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/6 "2017-10-08T07:08:01Z")

</div>

> [@JonMikelV](#):
>
> DUPLICATI\_\_PARSED\_RESULT

That would help me achieve what I want. However, the DUPLICATI\_\_PARSED\_RESULT is not shown to me, only these:

```
DUPLICATI__backup_name=nodered
DUPLICATI__block_hash_algorithm=SHA256
DUPLICATI__blocksize=102400b
DUPLICATI__compression_module=zip
DUPLICATI__dblock_size=50mb
DUPLICATI__dbpath=/config/ZSXXMASDPH.sqlite
DUPLICATI__disable_module=console-password-input
DUPLICATI__encryption_module=aes
DUPLICATI__EVENTNAME=AFTER
DUPLICATI__file_hash_algorithm=SHA256
DUPLICATI__keep_time=1M
DUPLICATI__LOCALPATH=/source/nodered/data/
DUPLICATI__main_action=Backup
DUPLICATI__OPERATIONNAME=Backup
DUPLICATI__passphrase=OBFUSCATED
DUPLICATI__REMOTEURL=googledrive://nodered?authid=OBFUSCATED
DUPLICATI__RESULTFILE=/tmp/dup-33ef979a-d629-4257-93a7-f7cb44cc2ef3
DUPLICATI__run_script_after=/config/slack_msg.sh
DUPLICATI__throttle_download=
DUPLICATI__throttle_upload=

```

Could this be a bug? I’m running duplicati version 2.0.2.1 from the docker container provided by [linuxserver.io](http://linuxserver.io).

Update: just found out that this variable was [added on September 1st](https://github.com/duplicati/duplicati/commit/d6aa87e00390bff74c9e87119fe33869fdf823be#diff-832f50f0d74e2942b2c54ac68f47d965). I’ll try to update my duplicati (read: build my own container).

---

<div class="post-metadata">

**Author:** ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)\
**Post date:** [October 8, 2017, 12:02pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/7 "2017-10-08T12:02:34Z")

</div>

> [@randomname872634](#):
>
> just found out that this variable was added on September 1st

Oops, sorry about that - I don’t think I realized it wasn’t in the “standard” Docker yet since I don’t use the feature myself.

Good luck with your custom container! Let us know how it goes - or better yet, when you get it going post how you did it in the #How-To category. 😃

---

<div class="post-metadata">

**Author:** ![randomname872634](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/43a26b/32.png) [@randomname872634](https://forum.duplicati.com/u/randomname872634)\
**Post date:** [October 8, 2017, 2:39pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/8 "2017-10-08T14:39:08Z")

</div>

I’m using the [linuxserver.io docker container](https://hub.docker.com/r/linuxserver/duplicati/) and found out that updating to latest Canary from the Duplicati web interface was easiest. Not a good solution because a re-deploy of the container means I’ll have to do it again, but good enough for now.

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [October 12, 2017, 11:59am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/9 "2017-10-12T11:59:24Z")

</div>

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

Maybe we should make a Slack module, so it is a matter of supplying the channel and API token.

---

<div class="post-metadata">

**Author:** ![JonMikelV](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@JonMikelV](https://forum.duplicati.com/u/JonMikelV)\
**Post date:** [October 12, 2017, 2:56pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/10 "2017-10-12T14:56:54Z")

</div>

> [@randomname872634](#):
>
> Not a good solution because a re-deploy of the container means I’ll have to do it again, but good enough for now.

I’m still new to Docker so maybe there’s a taboo against this but couldn’t a “Duplicati Canary” container be created & maintained with the latest Canary versions?

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [October 12, 2017, 7:55pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/11 "2017-10-12T19:55:31Z")

</div>

Yes, it could. It would also be easy to integrate with the release build script.

It would probably just be “derive from the mono image, then install unzip, then download and unzip the canary.zip, then run Duplicati.Server.exe”

---

<div class="post-metadata">

**Author:** ![herbert](https://forum.duplicati.com/user_avatar/forum.duplicati.com/herbert/32/1865_2.png) [@herbert](https://forum.duplicati.com/u/herbert)\
**Post date:** [September 7, 2019, 8:05pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/12 "2019-09-07T20:05:02Z")

</div>

hi,

did anything happen?  
would also like to see some kind of messenger integration like slack, discord, nextcloud (talk) or mastodon etc

---

<div class="post-metadata">

**Author:** ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)\
**Post date:** [September 8, 2019, 7:03pm UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/13 "2019-09-08T19:03:53Z")

</div>

[Apprise - Push Notifications that work with just about every platform!](https://github.com/caronc/apprise) is a push notification specialist that supports many but not all of the services mentioned. It can probably be run directly, or by integration with  
[Announcing dupReport - A Duplicati Email Report Summary Generator](https://forum.duplicati.com/t/announcing-dupreport-a-duplicati-email-report-summary-generator/1116) (presumably with higher latency).

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [September 17, 2019, 8:24am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/14 "2019-09-17T08:24:33Z")

</div>

> [@herbert](#):
>
> did anything happen?

Yes, Docker images are now created as part of the build process:  
[https://hub.docker.com/r/duplicati/duplicati](https://hub.docker.com/r/duplicati/duplicati)

> [@herbert](#):
>
> would also like to see some kind of messenger integration like slack, discord, nextcloud (talk) or mastodon etc

The most flexible way is to do it in a script, as shown by @randomname872634

Slack and Discord both supports a simple API for sending a POST message. I assume NextCloud and Mastodon have similar features.

If someone wants to develop a more streamlined integration for one of the providers, there is basic HTTP post code here:

- [duplicati/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs at master · duplicati/duplicati · GitHub](https://github.com/duplicati/duplicati/blob/master/Duplicati/Library/Modules/Builtin/SendHttpMessage.cs)

It would be a fairly simple change, mostly deciding which parameters to expose (channel name, token, avatar, etc). A good “getting started” project for contributing to Duplicati.

---

<div class="post-metadata">

**Author:** ![herbert](https://forum.duplicati.com/user_avatar/forum.duplicati.com/herbert/32/1865_2.png) [@herbert](https://forum.duplicati.com/u/herbert)\
**Post date:** [September 17, 2019, 9:00am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/15 "2019-09-17T09:00:42Z")

</div>

> [@kenkendk](#):
>
> Yes, Docker images are now created as part of the build process:  
> [Docker](https://hub.docker.com/r/duplicati/duplicati)

Sorry didn’t want to be rude 🙂  
But I am using the docker image for quite some time already, with automatic updates using watchtower and all I can say - rock solid 😃

And thanks for the rest 🙂 of the information.

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [September 17, 2019, 9:57am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/16 "2019-09-17T09:57:09Z")

</div>

> [@herbert](#):
>
> Sorry didn’t want to be rude

I did not read it as being rude. I thought you were requesting status on the Docker builds, but since you are already using them, did you ask for something else?

---

<div class="post-metadata">

**Author:** ![herbert](https://forum.duplicati.com/user_avatar/forum.duplicati.com/herbert/32/1865_2.png) [@herbert](https://forum.duplicati.com/u/herbert)\
**Post date:** [September 17, 2019, 10:59am UTC](https://forum.duplicati.com/t/posting-duplicati-backup-events-to-slack-channel/931/17 "2019-09-17T10:59:51Z")

</div>

I was actually only interested in the slack notification status, because this is something I would like to use, but I got my answer anyhow.
