From c362460b86e351f5c1b91cc2667b0919bfa47574 Mon Sep 17 00:00:00 2001 From: alessandrovitali Date: Thu, 3 Sep 2026 20:39:45 +0200 Subject: [PATCH] fix fragile tasks --- roles/backup/tasks/main.yml | 7 ++++--- roles/backup/templates/restic-backup.sh.j2 | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml index 22f4bc7..cb96323 100644 --- a/roles/backup/tasks/main.yml +++ b/roles/backup/tasks/main.yml @@ -3,6 +3,7 @@ ansible.builtin.apt: name: restic state: present + update_cache: true - name: Initialize restic repository environment: @@ -11,11 +12,11 @@ AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key }}" AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_key }}" block: - - name: Check if already initialized - ansible.builtin.command: restic snapshots + - name: Check if repository is initialized + command: restic cat config register: restic_check - failed_when: false changed_when: false + failed_when: false - name: Initialize repository ansible.builtin.command: restic init diff --git a/roles/backup/templates/restic-backup.sh.j2 b/roles/backup/templates/restic-backup.sh.j2 index 77b76d2..d63aed6 100644 --- a/roles/backup/templates/restic-backup.sh.j2 +++ b/roles/backup/templates/restic-backup.sh.j2 @@ -3,11 +3,7 @@ set -e -# Source environment variables if running manually/outside Systemd -if [ -f /etc/restic-backup.env ]; then - # shellcheck source=/dev/null - . /etc/restic-backup.env -fi +## Environment is injected by the systemd unit via EnvironmentFile=/etc/restic-backup.env. Run manually with: systemctl start restic-backup.service echo "Starting Restic Backup at $(date)"