rename server group

This commit is contained in:
Luc Stroobant 2017-10-01 19:51:38 +02:00
parent dc72e03bb3
commit a1209ca8c2
8 changed files with 37 additions and 33 deletions

View file

@ -14,7 +14,7 @@ fi
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 backupservers %}
{% for b in borgbackup_servers %}
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
/usr/local/bin/borg info $REPOSITORY::$2 {{ b.options }}
{% endfor %}
@ -26,7 +26,7 @@ if [ "$1" = "mount" ]
if [ -z "$2" ]; then printf "Select the backup-server\n"; exit 1; fi
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 backupservers %}
{% for b in borgbackup_servers %}
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
/usr/local/bin/borg mount $REPOSITORY::$3 $4 {{ b.options }}
if [ "$?" = "0" ]; then printf "Backup mounted on $4, do not forget to unmount!\n"; fi
@ -36,7 +36,7 @@ fi
if [ "$1" = "list" ]
then
{% for b in backupservers %}
{% for b in borgbackup_servers %}
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
printf "Archives on {{ b.fqdn }} :\n"
/usr/local/bin/borg list -v $REPOSITORY {{ b.options }}
@ -46,7 +46,7 @@ fi
if [ "$1" = "init" ]
then
{% for b in backupservers %}
{% for b in borgbackup_servers %}
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
borg init $REPOSITORY {{ b.options }}
{% endfor %}
@ -62,7 +62,7 @@ if [ "$1" = "backup" ]
{{ precommand }}
{% endfor %}
{% for b in backupservers %}
{% for b in borgbackup_servers %}
printf "Backing up to {{ b.fqdn }} :\n"
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}

View file

@ -5,9 +5,9 @@
# Don't put it on the backup server, it contains all borg secrets!
{% for h in groups['all'] %}
{% if hostvars[h].borgbackup_required is defined and hostvars[h].borgbackup_required %}
{% if hostvars[h].borgbackup_required | default(True) %}
# Host: {{ h }}
{% for b in hostvars[h].backupservers %}
{% for b in hostvars[h].borgbackup_servers %}
{% if hostvars[h].borgbackup_managementstation is defined and inventory_hostname == hostvars[h].borgbackup_managementstation %}
export BORG_PASSPHRASE={{ hostvars[h].borgbackup_passphrase }}
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ h }}

View file

@ -1,5 +1,5 @@
# backup hosts
{% for b in backupservers %}
{% for b in borgbackup_servers %}
Host {{ b.fqdn }}
StrictHostKeyChecking no
{% if b.port is defined %}