Splitting REPOSITORY into multiple line jinja if statement for clarity
This commit is contained in:
parent
e2039b742d
commit
9400488267
@ -15,7 +15,11 @@ if [ "$1" = "info" ]
|
||||
then
|
||||
if [ -z "$2" ]; then printf "run $0 with list and use the backup-tag to request information\n"; exit 1; fi
|
||||
{% for b in borgbackup_servers %}
|
||||
REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
/usr/local/bin/borg info {{ b.options }} $REPOSITORY::$2
|
||||
{% endfor %}
|
||||
exit 0
|
||||
@ -27,7 +31,11 @@ if [ "$1" = "mount" ]
|
||||
if [ -z "$3" ]; then printf "Select the backup to mount\n"; exit 1; fi
|
||||
if [ -z "$4" ]; then printf "Select the path to mount the backup on\n"; exit 1; fi
|
||||
{% for b in borgbackup_servers %}
|
||||
REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
/usr/local/bin/borg mount {{ b.options }} $REPOSITORY::$3 $4
|
||||
if [ "$?" = "0" ]; then printf "Backup mounted on $4, do not forget to unmount!\n"; fi
|
||||
exit 0
|
||||
@ -37,7 +45,11 @@ fi
|
||||
if [ "$1" = "list" ]
|
||||
then
|
||||
{% for b in borgbackup_servers %}
|
||||
REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
printf "Archives on {{ b.fqdn }} :\n"
|
||||
/usr/local/bin/borg list {{ b.options }} -v $REPOSITORY
|
||||
{% endfor %}
|
||||
@ -47,7 +59,11 @@ fi
|
||||
if [ "$1" = "init" ]
|
||||
then
|
||||
{% for b in borgbackup_servers %}
|
||||
REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
/usr/local/bin/borg init --encryption={{ borgbackup_encryption_mode }}{% if borgbackup_appendonly_repoconfig %} --append-only{% endif %} {{ b.options }} $REPOSITORY
|
||||
{% endfor %}
|
||||
exit 0
|
||||
@ -64,7 +80,11 @@ if [ "$1" = "backup" ]
|
||||
|
||||
{% for b in borgbackup_servers %}
|
||||
printf "Backing up to {{ b.fqdn }} :\n"
|
||||
REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
|
||||
/usr/local/bin/borg create --progress --compression {{ borgbackup_compression }} --stats {{ b.options }} $REPOSITORY::$date {% for dir in borgbackup_include %}{{ dir }} {% endfor %}{% if automysql.stat.isdir is defined and automysql.stat.isdir == True %}/var/lib/automysqlbackup{% endif %} {% for dir in borgbackup_exclude %} --exclude '{{ dir }}'{% endfor %}
|
||||
|
||||
|
@ -14,7 +14,11 @@
|
||||
{% if hostvars[h].borgbackup_management_station is defined and inventory_hostname == hostvars[h].borgbackup_management_station %}
|
||||
{% for b in hostvars[h].borgbackup_servers %}
|
||||
# {{ b.fqdn }}
|
||||
REPOSITORY={% if b.type == 'hetzner' %}ssh://{% endif %}{{ b.user }}@{{ b.fqdn }}:{% if b.type == 'hetzner' %}23/./{% endif %}{{ b.home }}{{ b.pool }}/{{ h }}
|
||||
{% 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 %}
|
||||
/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 }}
|
||||
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user