unable to use runtime variables for notification #384

Closed
opened 2020-12-26 06:22:24 +00:00 by sandrotosi · 10 comments

hello,
after reading https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#error-hooks i setup this configuration option:

hook:
   after_everything:
        - /bin/echo -e "Error:\n"{error}"\n\nOutput:\n"{output} | mail -s "Borgmatic backup" MYADDRESS

but the mail text i actually receive is:

Error:
{error}

Output:
{output}

am i doing something wrong? i even tried with /bin/echo -e "Error:\n{error}\n\nOutput:\n{output}" (with the variables within double quotes with the rest of the text) but same result

thanks!

hello, after reading https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/#error-hooks i setup this configuration option: ``` hook: after_everything: - /bin/echo -e "Error:\n"{error}"\n\nOutput:\n"{output} | mail -s "Borgmatic backup" MYADDRESS ``` but the mail text i actually receive is: ``` Error: {error} Output: {output} ``` am i doing something wrong? i even tried with `/bin/echo -e "Error:\n{error}\n\nOutput:\n{output}"` (with the variables within double quotes with the rest of the text) but same result thanks!
Author

Can someone provide any input here? thanks!

Can someone provide any input here? thanks!
Owner

Sorry for the delay here. The interpolated variables you're trying to use ({error} and {output}) are actually only available within the on_error hook, because that's the hook that's called with the error when one occurs! So you could try switching your configuration to this:

hook:
   on_error:
        - /bin/echo -e "Error:\n"{error}"\n\nOutput:\n"{output} | mail -s "Borgmatic backup" MYADDRESS

Let me know whether that works for you.

Sorry for the delay here. The interpolated variables you're trying to use (`{error}` and `{output}`) are actually only available within the `on_error` hook, because that's the hook that's called with the error when one occurs! So you could try switching your configuration to this: ```yaml hook: on_error: - /bin/echo -e "Error:\n"{error}"\n\nOutput:\n"{output} | mail -s "Borgmatic backup" MYADDRESS ``` Let me know whether that works for you.
witten added the
question / support
label 2021-01-08 21:04:25 +00:00
Author

thanks @witten now it's a bit more clear! What i was trying to achive was to get either a {error} if there was one, and the backup {output} at the end of the cronjob, so that i would be aware of both a positive or a negative outcome.

i'm wondering if there's a way to get a brief summary of the result of a backup via email, just so that i can know thta the backup completed and if there's been any error

thanks!

thanks @witten now it's a bit more clear! What i was trying to achive was to get either a `{error}` if there was one, and the backup `{output}` at the end of the cronjob, so that i would be aware of both a positive or a negative outcome. i'm wondering if there's a way to get a brief summary of the result of a backup via email, just so that i can know thta the backup completed and if there's been any error thanks!
Owner

How are you running borgmatic? If you run it with a job runner like cron or systemd, that should collect any output and email you in the case of output or error (depending on configuration).

An alternative would be to use borgmatic's integration with monitoring services like Healthchecks.io. With Healthchecks in particular, all borgmatic logs are sent over to that service, and it can alert you on various conditions.

How are you running borgmatic? If you run it with a job runner like cron or systemd, that should collect any output and email you in the case of output or error (depending on configuration). An alternative would be to use borgmatic's integration with [monitoring services](https://torsion.org/borgmatic/docs/how-to/monitor-your-backups/) like Healthchecks.io. With Healthchecks in particular, all borgmatic logs are sent over to that service, and it can alert you on various conditions.
Author

i have a daily cron that run borgmatic (that's the whole command-line), but it doesnt produce any output; should i run it with --stats or some other flags?

i have a daily cron that run `borgmatic` (that's the whole command-line), but it doesnt produce any output; should i run it with `--stats` or some other flags?
Owner

Yeah, you'll need to decide which output you're interested in. Some options are: --verbosity 1, --verbosity 2, --stats, and/or --files.

If you use one/some of those, I believe cron should send you the output!

Yeah, you'll need to decide which output you're interested in. Some options are: `--verbosity 1`, `--verbosity 2`, `--stats`, and/or `--files`. If you use one/some of those, I believe cron should send you the output!
Author

i played around with the options you mentioned, and for now i'm gonna stick with --stats.

please note neither --stats nor --files are present in the --help message, are they other switches that are missing?

i played around with the options you mentioned, and for now i'm gonna stick with `--stats`. please note neither `--stats` nor `--files` are present in the `--help` message, are they other switches that are missing?
Owner

Those are options for create (an implicit action when you just run borgmatic), so their help shows up in the output of borgmatic create --help.

Those are options for `create` (an implicit action when you just run `borgmatic`), so their help shows up in the output of `borgmatic create --help`.
Author

gotcha, thanks for your help!

gotcha, thanks for your help!
Owner

Sure thing!

Sure thing!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#384
No description provided.