From bea177dd347b8793cf554fb8c7396d38d46a0133 Mon Sep 17 00:00:00 2001 From: L3D Date: Wed, 2 Feb 2022 13:03:37 +0100 Subject: [PATCH] Archiv settings expanded --- defaults/main.yml | 8 ++++++ templates/includes/repo_todos.sh.j2 | 40 ++++++++++++++++++++++++++++- vars/main.yml | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3a2bb14..e74c2ca 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -28,6 +28,14 @@ restic_archiver__keep_weekly: 8 restic_archiver__keep_monthly: 16 restic_archiver__keep_yearly: 12 +restic_archiver__archive_keep: 5 +restic_archiver__archive_keep_hourly: 16 +restic_archiver__archive_keep_daily: 14 +restic_archiver__archive_keep_weekly: 8 +restic_archiver__archive_keep_monthly: 16 +restic_archiver__archive_keep_yearly: 12 + + # owner and user of all restic stuff restic_archiver__owner: 'root' restic_archiver__group: 'root' diff --git a/templates/includes/repo_todos.sh.j2 b/templates/includes/repo_todos.sh.j2 index e1bda1a..b6e4c8d 100644 --- a/templates/includes/repo_todos.sh.j2 +++ b/templates/includes/repo_todos.sh.j2 @@ -41,6 +41,44 @@ --prune {% endif %} {%- endmacro %} +{% macro retention_archive_pattern(repo) -%} + {% if repo.keep_last is defined and repo.archive_keep_last != None -%} + --keep-last {{ repo.archive_keep_last }} + {%- else -%} + --keep-last {{ restic_archiver__archive_keep }} + {%- endif %} \ + {% if repo.keep_hourly is defined and repo.archive_keep_hourly != None -%} + --keep-hourly {{ repo.archive_keep_hourly }} + {%- else -%} + --keep-hourly {{ restic_archiver__archive_keep_hourly }} + {%- endif %} \ + {% if repo.keep_daily is defined and repo.archive_keep_daily != None -%} + --keep-daily {{ repo.archive_keep_daily }} + {%- else -%} + --keep-daily {{ restic_archiver__archive_keep_daily }} + {%- endif %} \ + {% if repo.keep_weekly is defined and repo.archive_keep_weekly != None -%} + --keep-weekly {{ repo.archive_keep_weekly }} + {%- else -%} + --keep-weekly {{ restic_archiver__archive_keep_weekly }} + {%- endif %} \ + {% if repo.keep_monthly is defined and repo.archive_keep_monthly != None -%} + --keep-monthly {{ repo.archive_keep_monthly }} + {%- else -%} + --keep-monthly {{ restic_archiver__archive_keep_monthly }} + {%- endif %} \ + {% if repo.keep_yearly is defined and repo.archive_keep_yearly != None -%} + --keep-yearly {{ repo.archive_keep_yearly }} + {%- else -%} + --keep-yearly {{ restic_archiver__archive_keep_yearly }} + {%- endif -%} + {% if repo.keep_within is defined and repo.archive_keep_within != None %} \ + --keep-within {{ repo.archive_keep_within }} {% endif -%} + {%- if repo.prune|default(restic_archiver__prune) %} \ + --prune {% endif %} +{%- endmacro %} + + {# START DOING STUFF INSIDE THE RESTIC REPO FOR LOOP #} @@ -137,7 +175,7 @@ EOT export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}' 2>/dev/null BACKUP_NAME="{{ repo.name }}_archive" - restic {{ restic_archiver__default_opt }} forget {{ retention_pattern(repo) }} + restic {{ restic_archiver__default_opt }} forget {{ retention_archive_pattern(repo) }} {%- if repo.prune|default(restic_archiver__prune) %} restic {{ restic_archiver__default_opt }} prune echo "restic ARCHIVE prune done" diff --git a/vars/main.yml b/vars/main.yml index af43dec..89ac0ad 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 51 # should be int +playbook_version_number: 52 # should be int playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'