Update 'Readme.md'

This commit is contained in:
lasimik 2021-05-17 01:27:27 +00:00
parent c1947c178b
commit 83798c3696
1 changed files with 10 additions and 8 deletions

View File

@ -1,19 +1,18 @@
# Desktop notifications from borgmatic when it is run from systemd # Desktop notifications from borgmatic when it is run from systemd
How to set up desktop notifications to an arbitrary user, while borgmatic is automatically run from a systemd timer. That implies a Linux machine, of course. How to set up desktop notifications to an arbitrary user, while borgmatic is automatically run from a systemd timer. That implies a Linux machine, of course.
This includes workarounds for current (borgmatic 1.5.13, borg 1.1.16) limitations of borg/borgmatic. They may or may not be necessary in the future. This HowTo was written on 2021-05-17, some downloaded files may have changed since then. This includes workarounds for current (borgmatic 1.5.13, borg 1.1.16) limitations of borg/borgmatic. They may or may not be necessary in the future. This HowTo was written on 2021-05-17, some downloaded files may have changed since then.
--
The following needs to be set up for the notifications: The following needs to be set up for the notifications:
-- ---
### In the systemd timer ### In the systemd timer
The template from the borgmatic site (the`borgmatic.timer`) is fine, insert a string for `Description=…`, and set the `[Timer]` section if not already done. No special changes here. The template from the borgmatic site (the`borgmatic.timer`) is fine, insert a string for `Description=…`, and set the `[Timer]` section if not already done. No special changes here.
-- ---
### In the systemd service ### In the systemd service
@ -23,7 +22,7 @@ The line `CapabilityBoundingSet=…` must give the additional capabilities `AP_S
*_This means a softening of security settings._ Make sure all permissions on borgmatic and scripts are set correctly!* *_This means a softening of security settings._ Make sure all permissions on borgmatic and scripts are set correctly!*
-- ---
### In the borgmatic config ### In the borgmatic config
@ -42,7 +41,7 @@ hooks:
``` ```
(Note: The config file is in YAML, you cannot use the shell line continuation (" \\"). And use spaces, not tabs.) (Note: The config file is in YAML, you cannot use the shell line continuation (" \\"). And use spaces, not tabs.)
- ---
#### Notifications from a script #### Notifications from a script
Borgmatic calls an executable script that can do more magic and send the notifications in the same way as explained above. Borgmatic calls an executable script that can do more magic and send the notifications in the same way as explained above.
@ -70,7 +69,7 @@ sudo -u NAME DISPLAY=:0 \
``` ```
(Note: Line continuation and the use of variables make complexer notifications substantially easier to set up than in `config.yaml`.) (Note: Line continuation and the use of variables make complexer notifications substantially easier to set up than in `config.yaml`.)
--- ----
### Example for Overdue Backups Alert ### Example for Overdue Backups Alert
#### In the borgmatic config #### In the borgmatic config
@ -127,7 +126,8 @@ NOW=$(date +'%F %H:%M %Z')
BACKUPAGEHOURS=$(datediff -i "%a, %F %T %Z" -f "%rH" \ BACKUPAGEHOURS=$(datediff -i "%a, %F %T %Z" -f "%rH" \
"$LASTBACKUP" now) "$LASTBACKUP" now)
# ...as string for notifications, with removal of zero values # ...as string for notifications, with removal of zero values
BACKUPAGESTRING=$(datediff -i "%a, %F %T %Z" -f "%rY years %rm months %rw weeks %rd days %rH hours %rM minutes" \ BACKUPAGESTRING=$(datediff -i "%a, %F %T %Z" \
-f "%rY years %rm months %rw weeks %rd days %rH hours %rM minutes" \
"$LASTBACKUP" now | sed -E 's/(0 years |0 months |0 weeks |0 days |0 hours)//g') "$LASTBACKUP" now | sed -E 's/(0 years |0 months |0 weeks |0 days |0 hours)//g')
# set message text # set message text
@ -159,3 +159,5 @@ else # backup age is 24 hours or less
fi fi
``` ```
![picture](https://projects.torsion.org/lasimik/borgmatic_notifications/raw/branch/master/borgmatic-notification.png)