From 83798c36968784e4ab87b04027e916fe95e71e55 Mon Sep 17 00:00:00 2001 From: lasimik Date: Mon, 17 May 2021 01:27:27 +0000 Subject: [PATCH] Update 'Readme.md' --- Readme.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Readme.md b/Readme.md index bc771ac..67a60a4 100644 --- a/Readme.md +++ b/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)