From e2039b742d2b347a817d39ea9217b6da79aa8721 Mon Sep 17 00:00:00 2001 From: Dieter Verhelst Date: Tue, 3 Jul 2018 07:27:50 +0200 Subject: [PATCH] Cleaner output of prune.sh generated template --- templates/prune.sh.j2 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/templates/prune.sh.j2 b/templates/prune.sh.j2 index d3e41eb..25755e7 100644 --- a/templates/prune.sh.j2 +++ b/templates/prune.sh.j2 @@ -1,3 +1,4 @@ +#jinja2:lstrip_blocks: True #!/bin/bash # This script is intended to run on a trusted management station to purge borg repo's in @@ -5,15 +6,18 @@ # Don't put it on the backup server, it contains all borg secrets! {% for h in groups['all'] %} - {% if hostvars[h].borgbackup_required | default(True) %} - # Host: {{ h }} + {% if hostvars[h].borgbackup_required | default(True) -%} + # Host: {{ h }} + + export BORG_PASSPHRASE={{ hostvars[h].borgbackup_passphrase }} + + {% if hostvars[h].borgbackup_management_station is defined and inventory_hostname == hostvars[h].borgbackup_management_station %} {% for b in hostvars[h].borgbackup_servers %} - {% if hostvars[h].borgbackup_management_station is defined and inventory_hostname == hostvars[h].borgbackup_management_station %} - export BORG_PASSPHRASE={{ hostvars[h].borgbackup_passphrase }} + # {{ b.fqdn }} REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ h }} /usr/local/bin/borg prune -v $REPOSITORY {{ b.options }} -H {{ hostvars[h].borgbackup_retention.hourly }} -d {{ hostvars[h].borgbackup_retention.daily }} -w {{ hostvars[h].borgbackup_retention.weekly }} -m {{ hostvars[h].borgbackup_retention.monthly }} -y {{ hostvars[h].borgbackup_retention.yearly }} - {% endif %} - {% endfor %} + {% endfor %} + {% endif %} {% endif %} {% endfor %}