2018-07-03 05:27:50 +00:00
|
|
|
#jinja2:lstrip_blocks: True
|
2017-10-01 17:24:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script is intended to run on a trusted management station to purge borg repo's in
|
|
|
|
# append-only mode.
|
|
|
|
# Don't put it on the backup server, it contains all borg secrets!
|
|
|
|
|
|
|
|
{% for h in groups['all'] %}
|
2018-07-03 05:27:50 +00:00
|
|
|
{% 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 %}
|
2017-10-01 17:51:38 +00:00
|
|
|
{% for b in hostvars[h].borgbackup_servers %}
|
2018-07-03 05:27:50 +00:00
|
|
|
# {{ b.fqdn }}
|
2018-08-16 07:01:44 +00:00
|
|
|
{% if b.type == 'hetzner' %}
|
|
|
|
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ h }}
|
|
|
|
{% else %}
|
|
|
|
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ h }}
|
|
|
|
{% endif %}
|
2017-10-01 17:24:50 +00:00
|
|
|
/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 }}
|
|
|
|
|
2018-07-03 05:27:50 +00:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2017-10-01 17:24:50 +00:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|