From c2532b64c4b644c30f237a90550b304b03335d26 Mon Sep 17 00:00:00 2001 From: Peter Leurs Date: Sun, 17 May 2026 22:37:04 +0200 Subject: [PATCH 1/3] add option to not warn on having a copy --- appinfo.yml | 4 ++++ backupmanager.j2 | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/appinfo.yml b/appinfo.yml index d16b1be..3df4d67 100644 --- a/appinfo.yml +++ b/appinfo.yml @@ -75,6 +75,10 @@ configdefinition: type: boolean default: false description: An idle repository will never give warnings that there are no recent backups + needscopy: + type: boolean + default: true + description: Will backup manager complain if there is no copy of the backup timeout: type: integer # note that the default is also in the python code - in case the host isn't filled in diff --git a/backupmanager.j2 b/backupmanager.j2 index 063e48b..d3ff954 100644 --- a/backupmanager.j2 +++ b/backupmanager.j2 @@ -243,7 +243,8 @@ for host in allhosts: timeout = hosts[host]["timeout"] if not idle: if not have_a_copy: - output_warning(f"We do not have a copy for {host}") + if hosts[host]["needscopy"]: + output_warning(f"We do not have a copy for {host}") if most_recent_backup_ts < time.time()-(timeout*24*3600): output_warning(f"Last backup for {host} is too old") From cd5a24786dac45745889c408c6faee2be0282949 Mon Sep 17 00:00:00 2001 From: Peter Leurs Date: Sun, 17 May 2026 22:44:51 +0200 Subject: [PATCH 2/3] upgrade backupmanager to v3 appinfo --- appinfo.yml | 13 ++++++++++--- backup-manager.timer.j2 | 3 ++- monitor.socket.j2 | 3 ++- monitor@.service.j2 | 5 +---- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/appinfo.yml b/appinfo.yml index 3df4d67..5e24bac 100644 --- a/appinfo.yml +++ b/appinfo.yml @@ -1,6 +1,14 @@ -mainunit: backup-manager.timer -mainunitfile: backup-manager.timer.j2 +version: 3 +mainunit: backup-manager +plugins: + - type: builtin + name: backups_none +enableunits: + - backup-manager.timer + - monitor.socket templatefiles: + - src: backup-manager.timer.j2 + dest: ~/.config/systemd/user/backup-manager.timer - src: backup-manager.service.j2 dest: ~/.config/systemd/user/backup-manager.service - src: backupmanager.j2 @@ -16,7 +24,6 @@ templatefiles: - src: monitor-test.sh.j2 dest: ~/monitor-test.sh mode: "0755" -backuptype: none configdefinition: "$id": "backup manager config" "$schema": "http://json-schema.org/draft-07/schema#" diff --git a/backup-manager.timer.j2 b/backup-manager.timer.j2 index cd9b9e5..8de83d0 100644 --- a/backup-manager.timer.j2 +++ b/backup-manager.timer.j2 @@ -1,5 +1,6 @@ [Unit] Description=Sync backups +PartOf={{ mainunit }} [Timer] OnCalendar=*-*-* 10:00:00 @@ -7,5 +8,5 @@ RandomizedDelaySec=3h Persistent=true [Install] -WantedBy=timers.target +WantedBy={{ mainunit }} diff --git a/monitor.socket.j2 b/monitor.socket.j2 index 17163d1..4aba33d 100644 --- a/monitor.socket.j2 +++ b/monitor.socket.j2 @@ -1,9 +1,10 @@ [Unit] Description=Execute Command Socket +PartOf={{ mainunit }} [Socket] ListenStream={{ statedir }}/{{ name }}.monitoring Accept=yes [Install] -WantedBy=sockets.target +WantedBy={{ mainunit }} diff --git a/monitor@.service.j2 b/monitor@.service.j2 index 55ee896..702d541 100644 --- a/monitor@.service.j2 +++ b/monitor@.service.j2 @@ -9,7 +9,4 @@ ExecStart={{ homedir }}/monitor.sh StandardInput=socket StandardOutput=socket TimeoutStopSec=5 -RuntimeMaxSec=10 - -[Install] -WantedBy=sockets.target \ No newline at end of file +RuntimeMaxSec=10 \ No newline at end of file From 3818707d450a70907848f225fa541eeb600ce1d8 Mon Sep 17 00:00:00 2001 From: Peter Leurs Date: Sun, 17 May 2026 23:12:55 +0200 Subject: [PATCH 3/3] migrated monitoring to built-in plugin --- appinfo.yml | 46 +++++++++++++++++++-------------------------- monitor.sh.j2 | 18 ------------------ monitor.socket.j2 | 10 ---------- monitor@.service.j2 | 12 ------------ 4 files changed, 19 insertions(+), 67 deletions(-) delete mode 100644 monitor.sh.j2 delete mode 100644 monitor.socket.j2 delete mode 100644 monitor@.service.j2 diff --git a/appinfo.yml b/appinfo.yml index 5e24bac..dbb2d29 100644 --- a/appinfo.yml +++ b/appinfo.yml @@ -3,9 +3,27 @@ mainunit: backup-manager plugins: - type: builtin name: backups_none + - type: builtin + name: monitoring + config: + checks: + - name: main + message: Backup manager activated + interval: 3600 + okvalue: active + command: systemctl is-active --user backup-manager.timer + - name: lastrun + message: Errors last run + interval: 3600 + okvalue: "" + command: cat {{ homedir }}/.backupmanager.errors + - name: lastrunrecent + message: Backup manager did not run recently + interval: 3600 + okvalue: "OK" + command: '[ -f {{ homedir }}/.backupmanager.errors ] && [ $(find {{ homedir }}/.backupmanager.errors -mtime -2) ] && echo "OK" || echo "outdated"' enableunits: - backup-manager.timer - - monitor.socket templatefiles: - src: backup-manager.timer.j2 dest: ~/.config/systemd/user/backup-manager.timer @@ -14,13 +32,6 @@ templatefiles: - src: backupmanager.j2 dest: ~/backupmanager mode: "0755" - - src: monitor@.service.j2 - dest: ~/.config/systemd/user/monitor@.service - - src: monitor.socket.j2 - dest: ~/.config/systemd/user/monitor.socket - - src: monitor.sh.j2 - dest: ~/monitor.sh - mode: "0755" - src: monitor-test.sh.j2 dest: ~/monitor-test.sh mode: "0755" @@ -93,22 +104,3 @@ configdefinition: description: Repositories where the latest backup is older then timeout days will give a warning that there are no recent backups required: - repos -exports: - monitoring: - checks: - - name: main - message: Backup manager activated - interval: 3600 - type: string - okvalue: active - - name: lastrun - message: Errors last run - interval: 3600 - type: string - okvalue: "" - - name: lastrunrecent - message: Backup manager did not run recently - interval: 3600 - type: string - okvalue: "OK" - diff --git a/monitor.sh.j2 b/monitor.sh.j2 deleted file mode 100644 index 0e8e932..0000000 --- a/monitor.sh.j2 +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -read -r command -case $command in - main) - systemctl is-active --user backup-manager.timer - ;; - lastrun) - cat {{ homedir }}/.backupmanager.errors - ;; - lastrunrecent) - [ -f {{ homedir }}/.backupmanager.errors ] && [ $(find {{ homedir }}/.backupmanager.errors -mtime -2) ] && echo "OK" || echo "outdated" - ;; - *) - echo "Parameter unknown" - ;; -esac - - diff --git a/monitor.socket.j2 b/monitor.socket.j2 deleted file mode 100644 index 4aba33d..0000000 --- a/monitor.socket.j2 +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Execute Command Socket -PartOf={{ mainunit }} - -[Socket] -ListenStream={{ statedir }}/{{ name }}.monitoring -Accept=yes - -[Install] -WantedBy={{ mainunit }} diff --git a/monitor@.service.j2 b/monitor@.service.j2 deleted file mode 100644 index 702d541..0000000 --- a/monitor@.service.j2 +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Execute Command Service -After=network.target -Requires=monitor.socket - -[Service] -Type=simple -ExecStart={{ homedir }}/monitor.sh -StandardInput=socket -StandardOutput=socket -TimeoutStopSec=5 -RuntimeMaxSec=10 \ No newline at end of file