New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of using Apprise with base image. #228
Comments
Suggesting maybe an update to ./base/data/borgmatic.d/crontab.txt and the ./base/README.md. I am happy to make the changes. |
It's pretty simple!
Then you need a file which brings the Apprise configuration (according to the Apprise documentation it would also work via cli - but I prefer this variant):
Now we have to call the script after the backup. For this I create a run.sh like it is the case with msmtp:
Now the crontab.txt must still be adapted:
Last but not least the
Of course you can use a variable here but faultiness in this instruction wins :D |
Wow! Thanks for the write-up and the PR @jonathan8devs I know you started with "It's pretty simple!" but I can't help thinking this is way more complex than it should be..... Apprise has a CLI (and it can take the notification body from stdin) so the python doesn't seem necessary. I raised this issue to create discussion and see how others are using apprise and hopefully get the recommended method added to the docs. I've actually just been running the following for a bit without issues. It doesn't change the message based on a failure or not, but it can be added with an if-else+subject_prefix like you have. I've been using email and signal alerts with apprise for the last few weeks without issues (Only show email example below). #!/bin/bash
$MAIL_SUBJECT="Subject Message"
APPRISE_MAIL_URI="mailto://$MAIL_FROM:$MAIL_PASSWORD@gmail.com/$MAIL_TO"
/usr/local/bin/borgmatic --stats -v 0 2>&1 | apprise -vv -t "$MAIL_SUBJECT" "$APPRISE_MAIL_URI" |
Sorry I've been afk guys! Been absolutely inundated at work! @grantbevis - would you be able to take point until I can have a proper look? I don't want to glance over what looks to be an amazing bit of work! |
data/scripts/run.sh Does the "set -o pipefail" really catch the exitcodes of each individual invocation of borg by borgmatic and throw out the highest exitcode overall at the end? With my installation the create action exits often with rc1/warning (files changed) but $? is "0" after all actions. Is that expected behaviour? |
FYI borgmatic now includes native support for Apprise in main. This will be part of the next release: https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#apprise-hook |
That's great news! Once my server is back up and running, I'm going to try and migrate docker borgmatic to s6, remove supercronic in favour of the inbuilt cron, and I'll also remove apprise as it'll be included. That'll definitely slim things up somewhat, and we'll close this ticket once that change goes through. |
Agreed this is great news. Just note that apprise won't be installed with borgmatic by default. It is an extras package with no version specified. Up to you if you want to still control the apprise package version in the docker image, or install borgmatic with I would suggest locking the version. I've been involved a bit with the apprise and apprise-api projects recently and I've witnessed changes/releases get pushed through quickly without much testing and the behaviour does not match the documentation. Patch/fix releases are common, up to you how you want to handle this. |
I'll close this issue. An example of using Apprise with borgmatic 1.8.4 can be found at the link above. |
I revisited this topic recently as I am also writing for a German blog. The guide there was getting outdated, and I wanted to update it. The simplest way to set up a regular backup with log handling is as follows: Crontab.txt */5 * * * * PATH=$PATH:/usr/local/bin /usr/local/bin/borgmatic --stats -v 0 > /tmp/backup_run.log Config.yaml before_backup:
- echo "Starting a backup job."
after_backup:
- echo "Backup created."
- apprise -vv -t "your-subdomain.example.com - BorgBackup" -b "$(cat /tmp/backup_run.log)" "mailtos://smtp.example.com:587?user=info@example.com&pass=YourSecurePassword&from=server@example.com"
on_error:
- echo "Error while creating a backup." |
Thanks for sharing @jonathan8devs , that approach is nice and simple. Also makes it easy to send a different notification |
Hi, I know that Apprise was added to the base image a while back. I can't find any examples of how to use it though (in the context of a borgmatic backup via cron).
I am wanting to migrate away from the msmtp image, as I use apprise on a few other projects for email alerts due to being easier to install and setup in a container than msmtp.
How are you guys using it (just piping the output of borgmatic into apprise?) and could the base README be updated to have an example?
@modem7 I know you are spearheading apprise. Thanks!
The text was updated successfully, but these errors were encountered: