commit
4475c07bc2
@ -33,8 +33,8 @@ borgbackup_retention:
|
|||||||
yearly: 1
|
yearly: 1
|
||||||
|
|
||||||
borgbackup_cron_day: "*"
|
borgbackup_cron_day: "*"
|
||||||
borgbackup_cron_hour: "{{ 5|random }}"
|
borgbackup_cron_hour: "{{ 5|random(seed=inventory_hostname) }}"
|
||||||
borgbackup_cron_minute: "{{ 59|random }}"
|
borgbackup_cron_minute: "{{ 59|random(seed=inventory_hostname) }}"
|
||||||
|
|
||||||
borgbackup_appendonly: False
|
borgbackup_appendonly: False
|
||||||
borgbackup_appendonly_repoconfig: False
|
borgbackup_appendonly_repoconfig: False
|
||||||
|
@ -15,7 +15,11 @@ if [ "$1" = "info" ]
|
|||||||
then
|
then
|
||||||
if [ -z "$2" ]; then printf "run $0 with list and use the backup-tag to request information\n"; exit 1; fi
|
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 %}
|
{% 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
|
/usr/local/bin/borg info {{ b.options }} $REPOSITORY::$2
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
exit 0
|
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 "$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
|
if [ -z "$4" ]; then printf "Select the path to mount the backup on\n"; exit 1; fi
|
||||||
{% for b in borgbackup_servers %}
|
{% 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
|
/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
|
if [ "$?" = "0" ]; then printf "Backup mounted on $4, do not forget to unmount!\n"; fi
|
||||||
exit 0
|
exit 0
|
||||||
@ -37,7 +45,11 @@ fi
|
|||||||
if [ "$1" = "list" ]
|
if [ "$1" = "list" ]
|
||||||
then
|
then
|
||||||
{% for b in borgbackup_servers %}
|
{% 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"
|
printf "Archives on {{ b.fqdn }} :\n"
|
||||||
/usr/local/bin/borg list {{ b.options }} -v $REPOSITORY
|
/usr/local/bin/borg list {{ b.options }} -v $REPOSITORY
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -47,7 +59,11 @@ fi
|
|||||||
if [ "$1" = "init" ]
|
if [ "$1" = "init" ]
|
||||||
then
|
then
|
||||||
{% for b in borgbackup_servers %}
|
{% 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
|
/usr/local/bin/borg init --encryption={{ borgbackup_encryption_mode }}{% if borgbackup_appendonly_repoconfig %} --append-only{% endif %} {{ b.options }} $REPOSITORY
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
exit 0
|
exit 0
|
||||||
@ -64,7 +80,11 @@ if [ "$1" = "backup" ]
|
|||||||
|
|
||||||
{% for b in borgbackup_servers %}
|
{% for b in borgbackup_servers %}
|
||||||
printf "Backing up to {{ b.fqdn }} :\n"
|
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 %}
|
/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 %}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#jinja2:lstrip_blocks: True
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script is intended to run on a trusted management station to purge borg repo's in
|
# This script is intended to run on a trusted management station to purge borg repo's in
|
||||||
@ -5,15 +6,22 @@
|
|||||||
# Don't put it on the backup server, it contains all borg secrets!
|
# Don't put it on the backup server, it contains all borg secrets!
|
||||||
|
|
||||||
{% for h in groups['all'] %}
|
{% for h in groups['all'] %}
|
||||||
{% if hostvars[h].borgbackup_required | default(True) %}
|
{% if hostvars[h].borgbackup_required | default(True) -%}
|
||||||
# Host: {{ h }}
|
# Host: {{ h }}
|
||||||
{% 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 }}
|
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 %}
|
||||||
|
# {{ b.fqdn }}
|
||||||
|
{% 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 }}
|
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 }}
|
/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 %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user