From 0be7583911bfe15276b736697caebb3752da56b6 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Tue, 21 Jul 2026 12:41:07 +0200 Subject: Fix restic install and add backup role Co-Authored-By: Claude.ai --- roles/backup/templates/backup-systemd.sh.j2 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 roles/backup/templates/backup-systemd.sh.j2 (limited to 'roles/backup/templates/backup-systemd.sh.j2') diff --git a/roles/backup/templates/backup-systemd.sh.j2 b/roles/backup/templates/backup-systemd.sh.j2 new file mode 100644 index 00000000..24be22ea --- /dev/null +++ b/roles/backup/templates/backup-systemd.sh.j2 @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +# shellcheck source=/dev/null +source "${CREDENTIALS_DIRECTORY}/{{ backup_name }}-backup.env" + +export RESTIC_REPOSITORY="${BACKUP_REPO}" +export RESTIC_PASSWORD="${BACKUP_PASSWORD}" +export AWS_ACCESS_KEY_ID="${BACKUP_ACCESS_KEY_ID}" +export AWS_SECRET_ACCESS_KEY="${BACKUP_SECRET_ACCESS_KEY}" + +CACHE_DIR="/var/cache/{{ backup_name }}-backup" + +restic --cache-dir "$CACHE_DIR" snapshots &>/dev/null || restic --cache-dir "$CACHE_DIR" init + +restic --cache-dir "$CACHE_DIR" backup {{ backup_paths | map('quote') | join(' ') }} + +restic --cache-dir "$CACHE_DIR" forget \ + --keep-daily {{ backup_retention_daily }} \ + --keep-weekly {{ backup_retention_weekly }} \ + --keep-monthly {{ backup_retention_monthly }} \ + --prune -- cgit v1.2.3