From 9d4a7bfb44fb9b0c740ceb495464d125dd54542c Mon Sep 17 00:00:00 2001 From: "pulsar89.5" Date: Wed, 20 Dec 2023 09:56:51 +0100 Subject: [PATCH] feat: Add borgmatic actions --- defaults/main.yml | 2 ++ templates/borgmatic.service.j2 | 2 ++ templates/borgmatic.timer.j2 | 2 ++ templates/config.yaml.j2 | 18 +++++++++++++++--- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index a740a89..94169b0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -32,4 +32,6 @@ borgmatic_name: "{{ inventory_hostname }}_{now}" borgmatic_compression: none borgmatic_passphrase: "" +borgmatic_actions: {} + borgmatic_restore_first: false diff --git a/templates/borgmatic.service.j2 b/templates/borgmatic.service.j2 index 555e154..36a48ad 100644 --- a/templates/borgmatic.service.j2 +++ b/templates/borgmatic.service.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + [Unit] Description=borgmatic backup Wants=network-online.target diff --git a/templates/borgmatic.timer.j2 b/templates/borgmatic.timer.j2 index d51c9b2..4a98b80 100644 --- a/templates/borgmatic.timer.j2 +++ b/templates/borgmatic.timer.j2 @@ -1,3 +1,5 @@ +# {{ ansible_managed }} + [Unit] Description=Run borgmatic backup diff --git a/templates/config.yaml.j2 b/templates/config.yaml.j2 index 0ea0028..4549a71 100644 --- a/templates/config.yaml.j2 +++ b/templates/config.yaml.j2 @@ -1,4 +1,5 @@ --- +# {{ ansible_managed }} repositories: {% for repository in borgmatic_repositories %} @@ -35,6 +36,17 @@ healthchecks: - finish - fail -keep_daily: {{ borgmatic_retention.daily }} -keep_monthly: {{ borgmatic_retention.monthly }} -keep_weekly: {{ borgmatic_retention.weekly }} +{% if borgmatic_retention | length > 0 %} +{% for param, value in borgmatic_retention.items() %} +keep_{{ param }}: {{ value }} +{% endfor %} +{% endif %} + +{% if borgmatic_actions | length > 0 %} +{% for param, values in borgmatic_actions.items() %} +{{ param }}: +{% for value in values %} + - {{ value }} +{% endfor %} +{% endfor %} +{% endif %}