offen / docker-volume-backup

Backup Docker volumes locally or to any S3, WebDAV, Azure Blob Storage, Dropbox or SSH compatible storage
https://offen.github.io/docker-volume-backup/
Mozilla Public License 2.0
2.13k stars 85 forks source link

Notifications on failed backups #23

Closed m90 closed 2 years ago

m90 commented 3 years ago

On failed backups, the image could send notifications so consumers do know about their backups being potentially unavailable.

Easy options would be:

m90 commented 3 years ago

Email notifications are now implemented after merging #24 which caters for my personal needs and use cases.

I am leaving this issue open in case anyone else has other requirements and wants to add them. I'd be happy to help and review PRs for adding other means of sending notifications.

MMauro94 commented 2 years ago

@m90 would you consider adding an all-in-one solution regarding notifications, so that anyone can choose the notification service they want? For instance I already use Telegram for a number of things, and I'd love to be able to add backups to it.

I know of Apprise which also has a handy CLI, but it's written in Python so it would have to be installed on the final image, and I know you're concerned about image size. I don't know if something similar written in Go already exists.

m90 commented 2 years ago

I would be happy to add a all-in-one solution like that in case it checks those two boxes:

Apprise probably won't work as you mentioned. I found this on a quick search though https://github.com/containrrr/shoutrrr

MMauro94 commented 2 years ago

That seems to check all the boxes. The email API can be emulated by using the smtp:// URL schema.

Sadly I have zero experience in Go, otherwise I'd start working on a PR

m90 commented 2 years ago

@MMauro94 There's a PR adding shoutrrr here https://github.com/offen/docker-volume-backup/pull/37 - I will need to do some more testing before I release this, but in case you want to give it a go already, it would be much appreciated if you could build an image off that branch (docker build -t offen/docker-volume-backup:notifications . from the repo root should be all that is needed) and see if it works for your use case as well.

MMauro94 commented 2 years ago

@m90 That was fast! I tried the branch with my telegram bot and it works perfectly.

Here's the message I got when I put the archive mount in read-only mode: image

Another small suggestion: add a config flag to enable sending a message also when the backup completes successfully.

In any case, thanks for the great work! If you need me to do some more testing, don't hesitate to ask

m90 commented 2 years ago

Thank you very much for testing this, good to know it works well for you too.

add a config flag to enable sending a message also when the backup completes successfully.

I've been pondering this too for a while but I've always thought "let's wait until someone requests it" so I guess here we are :sweat_smile:

It's relatively simple to add this given the current setup, the only challenge will be finding a good API for setting the config values.

One could either use something like log levels:

NOTIFICATION_LEVEL="info|warn|error" # default is error

or just a binary switch

NOTIFICATION_WHEN="failure|always" # default is failure

What do you think?

MMauro94 commented 2 years ago

I certainly like the flexibility given by NOTIFICATION_LEVEL more, however there are two things to consider:

It depends on how much future-proof you want to be. If I'm right and the notification level requires that much work, I'd go with the binary switch and change it in a future release only if it's needed.

m90 commented 2 years ago

This (both multiple notification backends as well as notification levels, info and errorfor now) is now released as v2.6.0.