Add restic-report example and systemd service files

This commit is contained in:
Alexander Schäferdiek 2022-06-30 00:13:32 +02:00
parent 7423cdd0a8
commit bb97797154
8 changed files with 87 additions and 33 deletions

View file

@ -0,0 +1,16 @@
[Unit]
Description=Run restic report script for %I utilizing /etc/restic/%I/report.sh file using env /etc/restic/%I/env
OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target
After=network-online.target
Requires=network-online.target
[Service]
Type=oneshot
ExecStart=sh /etc/restic/%I/report.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
EnvironmentFile=/etc/restic/%I/env
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,9 @@
[Unit]
Description=Run restic report script for %I utilizing /etc/restic/%I/report.sh file using env /etc/restic/%I/env
[Timer]
OnCalendar=Sun 01:00:00
Persistent=true
[Install]
WantedBy=timers.target

View file

@ -0,0 +1,16 @@
[Unit]
Description=Run restic report script for %I utilizing ~/.config/restic/%I/report.sh file using env ~/.config/restic/%I/env
OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target
After=network-online.target
Requires=network-online.target
[Service]
Type=oneshot
ExecStart=sh %h/.config/restic/%I/report.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
EnvironmentFile=%h/.config/restic/%I/env
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,9 @@
[Unit]
Description=Run restic report script for %I utilizing ~/.config/restic/%I/report.sh file using env ~/.config/restic/%I/env
[Timer]
OnCalendar=Sun 01:00:00
Persistent=true
[Install]
WantedBy=timers.target

View file

@ -16,3 +16,4 @@ RESTIC_KEEP="--keep-daily 7 --keep-weekly 4 --keep-monthly 3"
# advanced parameters # advanced parameters
RESTIC_ADDITIONAL_CREATE_PARAMS="--one-file-system" RESTIC_ADDITIONAL_CREATE_PARAMS="--one-file-system"
#RESTIC_REPORT_MAIL=monitoring@mydomain.tld

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# adapt to your needs
# this serves as an example and assumes configured mailx
SNAPSHOTS=$(/usr/bin/restic snapshots -c)
STATS=$(/usr/bin/restic stats)
# output for stdin (service)
echo -e "$STATS\n\n$SNAPSHOTS"
# output for mail
me="$0"
echo -e "$STATS\n\n$SNAPSHOTS" | mailx -Ssendwait -s "[restic - $(hostname)] $me - REPORT" "${RESTIC_REPORT_MAIL}"

View file

@ -2,32 +2,21 @@
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
dotfiles\-system is a collection of helper systemd services, systemd timers and shell scripts for common configuration and tasks like dotfiles\-system is a collection of helper systemd services, systemd timers and shell scripts for common configuration and tasks like
. .
.IP "\(bu" 4 .IP "" 4
checking if systemd services and timers are running
. .
.IP "\(bu" 4 .nf
borgmatic backup
* checking if systemd services and timers are running
* borgmatic backup
* restic backup
* checking if docker containers are running
* batch docker\-compose upgrades
* docker housekeeping for removing unused docker containers, volumes and images
* dynamic dns update
* update check for pacman
* memory and disk checks
. .
.IP "\(bu" 4 .fi
restic backup
.
.IP "\(bu" 4
checking if docker containers are running
.
.IP "\(bu" 4
batch docker\-compose upgrades
.
.IP "\(bu" 4
docker housekeeping for removing unused docker containers, volumes and images
.
.IP "\(bu" 4
dynamic dns update
.
.IP "\(bu" 4
update check for pacman
.
.IP "\(bu" 4
memory and disk checks
. .
.IP "" 0 .IP "" 0
. .