From a8e118d267b444f6190add177b3b836e9afdb0dc Mon Sep 17 00:00:00 2001 From: cjones Date: Sat, 17 Oct 2026 22:03:02 -0400 Subject: [PATCH] Specify restic repository with fully-qualified domain name. Add service and timer unit definitions for restic backup and restic check to repository. --- devices/teal/config/etc/restic/default.env.sh | 2 +- .../etc/systemd/system/restic-backup@.service | 17 +++++++++++++++++ .../etc/systemd/system/restic-backup@.timer | 9 +++++++++ .../etc/systemd/system/restic-check@.service | 15 +++++++++++++++ .../etc/systemd/system/restic-check@.timer | 9 +++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 devices/teal/config/etc/systemd/system/restic-backup@.service create mode 100644 devices/teal/config/etc/systemd/system/restic-backup@.timer create mode 100644 devices/teal/config/etc/systemd/system/restic-check@.service create mode 100644 devices/teal/config/etc/systemd/system/restic-check@.timer diff --git a/devices/teal/config/etc/restic/default.env.sh b/devices/teal/config/etc/restic/default.env.sh index 1233da6..95c9ce9 100644 --- a/devices/teal/config/etc/restic/default.env.sh +++ b/devices/teal/config/etc/restic/default.env.sh @@ -16,7 +16,7 @@ # Envvars below will override those in _global.env.sh if present. -export RESTIC_REPOSITORY="sftp:sftpuser@Cygnus:/Backup/restic/teal" # *EDIT* fill with your repo name +export RESTIC_REPOSITORY="sftp:sftpuser@cygnus.objectbrokers.com:/Backup/restic/teal" # *EDIT* fill with your repo name # What to backup. Colon-separated paths e.g. to different mountpoints "/home:/mnt/usb_disk". # To backup only your home directory, set "/home/your-user" diff --git a/devices/teal/config/etc/systemd/system/restic-backup@.service b/devices/teal/config/etc/systemd/system/restic-backup@.service new file mode 100644 index 0000000..b3606cd --- /dev/null +++ b/devices/teal/config/etc/systemd/system/restic-backup@.service @@ -0,0 +1,17 @@ +[Unit] +Description=Backup with restic to Backblaze B2 +# Email on failure require special setup. See README.md +#OnFailure=status-email-user@%n.service +# Prevent backup on unmetered connection. Needs special setup. See README.md. +#Requires=nm-unmetered-connection.service +#After=nm-unmetered-connection.service + +[Service] +Type=simple +Nice=10 +# $HOME or $XDG_CACHE_HOME must be set for restic to find /root/.cache/restic/ +Environment="HOME=/root" +# pipefail: so that redirecting stderr from the script to systemd-cat does not hide the failed command from OnFailure above. +# Random sleep (in seconds): in the case of multiple backup profiles. Many restic instances started at the same time could case high load or network bandwith usage. +# `systemd-cat` allows showing the restic output to the systemd journal +ExecStart=/bin/bash -c 'set -o pipefail; ps cax | grep -q restic && sleep $(shuf -i 0-300 -n 1); source /etc/restic/%I.env.sh && /bin/restic_backup.sh 2>&1 | systemd-cat' diff --git a/devices/teal/config/etc/systemd/system/restic-backup@.timer b/devices/teal/config/etc/systemd/system/restic-backup@.timer new file mode 100644 index 0000000..c492c33 --- /dev/null +++ b/devices/teal/config/etc/systemd/system/restic-backup@.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Backup with restic on schedule + +[Timer] +OnCalendar=daily +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/devices/teal/config/etc/systemd/system/restic-check@.service b/devices/teal/config/etc/systemd/system/restic-check@.service new file mode 100644 index 0000000..92d35bb --- /dev/null +++ b/devices/teal/config/etc/systemd/system/restic-check@.service @@ -0,0 +1,15 @@ +[Unit] +Description=Check restic backup Backblaze B2 for errors +# Email on failure require special setup. See README.md +#OnFailure=status-email-user@%n.service +Conflicts=restic-backup.service +# Prevent backup on unmetered connection. Needs special setup. See README.md. +#Requires=nm-unmetered-connection.service +#After=nm-unmetered-connection.service + +[Service] +Type=simple +Nice=10 +# pipefail: so that redirecting stderr from the script to systemd-cat does not hide the failed command from OnFailure above. +# `systemd-cat`: allows showing the restic output to the systemd journal +ExecStart=/bin/bash -c 'set -o pipefail; source /etc/restic/%I.env.sh && /bin/restic_check.sh 2>&1 | systemd-cat' diff --git a/devices/teal/config/etc/systemd/system/restic-check@.timer b/devices/teal/config/etc/systemd/system/restic-check@.timer new file mode 100644 index 0000000..097fd1e --- /dev/null +++ b/devices/teal/config/etc/systemd/system/restic-check@.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Check restic backup Backblaze B2 for errors on a schedule + +[Timer] +OnCalendar=monthly +Persistent=true + +[Install] +WantedBy=timers.target