1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-role-borg/templates/backup.sh.j2

28 lines
1.1 KiB
Text
Raw Permalink Normal View History

2019-07-09 11:45:03 +02:00
#!/bin/sh
###############################################################################
# \_o< WARNING : This file is being managed by ansible! >o_/ #
# ~~~~ ~~~~ #
###############################################################################
2021-05-02 18:42:01 +02:00
set -eu
2019-07-16 12:04:53 +02:00
export HOME=/root
2019-08-22 19:10:35 +02:00
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2019-07-16 12:04:53 +02:00
export BORG_RSH="ssh -i /root/.ssh/borg"
2019-07-09 11:45:03 +02:00
{% for job in borg_jobs %}
2021-02-11 19:10:38 +01:00
{% if job.pre_command is defined %}
{{ job.pre_command }}
{% endif %}
2019-07-09 11:45:03 +02:00
{% if job.command_to_pipe is defined %}
{{ job.command_to_pipe }} | borg create borg@{{ borg_server }}:/srv/borg/repos/{{ inventory_hostname }}::{{ job.name }}-{now} -
2019-07-09 11:45:03 +02:00
{% else %}
borg create {% for exclude in job.exclude|default([]) %} --exclude {{ exclude }}{% endfor %} borg@{{ borg_server }}:/srv/borg/repos/{{ inventory_hostname }}::{{ job.name }}-{now} {{ job.path }}
2019-07-09 11:45:03 +02:00
{% endif %}
2021-02-11 19:10:38 +01:00
{% if job.post_command is defined %}
{{ job.post_command }}
{% endif %}
2019-07-09 11:45:03 +02:00
{% endfor %}
borg prune borg@{{ borg_server }}:/srv/borg/repos/{{ inventory_hostname }} {{ borg_prune_arguments }}