From ca5ef757f86ebc281c2b8d2003fd2f00dddaaa77 Mon Sep 17 00:00:00 2001 From: korenstin Date: Sat, 19 Apr 2025 15:38:15 +0200 Subject: [PATCH] Ajout de l'option force_calendar pour choisir l'heure des backups restic --- host_vars/tealc.adm.crans.org.yml | 2 ++ roles/restic-client/README.md | 2 ++ .../templates/systemd/system/restic-base.timer.j2 | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/host_vars/tealc.adm.crans.org.yml b/host_vars/tealc.adm.crans.org.yml index 20e4fee5..fb3e128f 100644 --- a/host_vars/tealc.adm.crans.org.yml +++ b/host_vars/tealc.adm.crans.org.yml @@ -48,12 +48,14 @@ loc_restic: - /etc - /var pool: + force_calendar: "5:00" to_exclude: - "*.pyc" - "\\#*\\#" - "*~" to_backup: - /pool/home + - /pool/mail retention: - [--keep-daily, 4] - [--keep-weekly, 4] diff --git a/roles/restic-client/README.md b/roles/restic-client/README.md index 7d07b7f5..eff3303a 100644 --- a/roles/restic-client/README.md +++ b/roles/restic-client/README.md @@ -9,6 +9,8 @@ la [documentation](gitlab.crans.org/nounous/documentation). glob_restic: (ou loc_restic dans host_vars) config: : + force_calendar: si n'existe pas, utilise une heure aléatoire, si existe + force une heure. to_exclude: chemins à ne pas backuper to_backup: chemins à backuper retention: règles de conservations diff --git a/roles/restic-client/templates/systemd/system/restic-base.timer.j2 b/roles/restic-client/templates/systemd/system/restic-base.timer.j2 index d7583d82..b132a45f 100644 --- a/roles/restic-client/templates/systemd/system/restic-base.timer.j2 +++ b/roles/restic-client/templates/systemd/system/restic-base.timer.j2 @@ -3,7 +3,11 @@ [Unit] [Timer] +{% if restic.config[item.0].force_calendar is defined %} +OnCalendar={{ restic.config[item.0].force_calendar }} +{% else %} OnCalendar={{ 24 | random(seed=inventory_hostname+item.0) }}:{{ 60 | random(seed=inventory_hostname+item.0) }} +{% endif %} Persistent=true [Install]