Compare commits
3 commits
8c603d6ebd
...
3818707d45
| Author | SHA1 | Date | |
|---|---|---|---|
| 3818707d45 | |||
| cd5a24786d | |||
| c2532b64c4 |
6 changed files with 36 additions and 73 deletions
61
appinfo.yml
61
appinfo.yml
|
|
@ -1,22 +1,40 @@
|
||||||
mainunit: backup-manager.timer
|
version: 3
|
||||||
mainunitfile: backup-manager.timer.j2
|
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
|
||||||
templatefiles:
|
templatefiles:
|
||||||
|
- src: backup-manager.timer.j2
|
||||||
|
dest: ~/.config/systemd/user/backup-manager.timer
|
||||||
- src: backup-manager.service.j2
|
- src: backup-manager.service.j2
|
||||||
dest: ~/.config/systemd/user/backup-manager.service
|
dest: ~/.config/systemd/user/backup-manager.service
|
||||||
- src: backupmanager.j2
|
- src: backupmanager.j2
|
||||||
dest: ~/backupmanager
|
dest: ~/backupmanager
|
||||||
mode: "0755"
|
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
|
- src: monitor-test.sh.j2
|
||||||
dest: ~/monitor-test.sh
|
dest: ~/monitor-test.sh
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
backuptype: none
|
|
||||||
configdefinition:
|
configdefinition:
|
||||||
"$id": "backup manager config"
|
"$id": "backup manager config"
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
|
|
@ -75,6 +93,10 @@ configdefinition:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
description: An idle repository will never give warnings that there are no recent backups
|
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:
|
timeout:
|
||||||
type: integer
|
type: integer
|
||||||
# note that the default is also in the python code - in case the host isn't filled in
|
# note that the default is also in the python code - in case the host isn't filled in
|
||||||
|
|
@ -82,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
|
description: Repositories where the latest backup is older then timeout days will give a warning that there are no recent backups
|
||||||
required:
|
required:
|
||||||
- repos
|
- 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"
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Sync backups
|
Description=Sync backups
|
||||||
|
PartOf={{ mainunit }}
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=*-*-* 10:00:00
|
OnCalendar=*-*-* 10:00:00
|
||||||
|
|
@ -7,5 +8,5 @@ RandomizedDelaySec=3h
|
||||||
Persistent=true
|
Persistent=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=timers.target
|
WantedBy={{ mainunit }}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,8 @@ for host in allhosts:
|
||||||
timeout = hosts[host]["timeout"]
|
timeout = hosts[host]["timeout"]
|
||||||
if not idle:
|
if not idle:
|
||||||
if not have_a_copy:
|
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):
|
if most_recent_backup_ts < time.time()-(timeout*24*3600):
|
||||||
output_warning(f"Last backup for {host} is too old")
|
output_warning(f"Last backup for {host} is too old")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Execute Command Socket
|
|
||||||
|
|
||||||
[Socket]
|
|
||||||
ListenStream={{ statedir }}/{{ name }}.monitoring
|
|
||||||
Accept=yes
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=sockets.target
|
|
||||||
|
|
@ -1,15 +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
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=sockets.target
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue