Browse Source

Update 'Readme.md'

master
lasimik 3 months ago
parent
commit
83798c3696
  1. 18
      Readme.md

18
Readme.md

@ -1,19 +1,18 @@
# 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.
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:
--
---
### 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.
--
---
### 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!*
--
---
### 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.)
-
---
#### 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.
@ -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`.)
---
----
### Example for Overdue Backups Alert
#### In the borgmatic config
@ -127,7 +126,8 @@ NOW=$(date +'%F %H:%M %Z')
BACKUPAGEHOURS=$(datediff -i "%a, %F %T %Z" -f "%rH" \
"$LASTBACKUP" now)
# ...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')
# set message text
@ -159,3 +159,5 @@ else # backup age is 24 hours or less
fi
```
![picture](https://projects.torsion.org/lasimik/borgmatic_notifications/raw/branch/master/borgmatic-notification.png)
Loading…
Cancel
Save