This commit is contained in:
Paul 2021-05-15 14:42:33 +02:00
commit ffa1e0a1aa
4 changed files with 15 additions and 3 deletions

View File

@ -3,6 +3,10 @@ borg:
enabled: true
run_user: dkron
working_dir: /opt/borg
default_dirs:
- bin
- logs
- scripts
pip_pkgs:
- borgbackup
- llfuse

View File

@ -1,5 +1,6 @@
---
include:
- dkron
- .pkgs
- .install
- .config

View File

@ -5,7 +5,7 @@ borg-working-dir:
- name: {{ borg.working_dir }}
- mode: 0700
{% for dir in ['bin', 'logs', 'scripts'] %}
{% for dir in borg.default_dirs %}
borg-working-dir-{{ dir }}:
file.directory:
- name: {{ borg.working_dir }}/{{ dir }}

View File

@ -1,7 +1,11 @@
#!/bin/bash
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
backup_name="{{ key }}"
{% if job.mountpoint is defined -%}
export MOUNTPOINT="{{ job.mountpoint|default('/mnt') }}"
if [[ $(mountpoint -q $MOUNTPOINT) -ne 0 ]]
@ -10,9 +14,12 @@ then
exit 2
fi
backup_name="{{ key }}"
repo_path=${MOUNTPOINT}/borg
{% else %}
repo_path={{ job.sshrepo|default('localhost::tmp') }}
{%- endif %}
export BORG_REPO=${MOUNTPOINT}/borg/${backup_name}
export BORG_REPO=$repo_path/${backup_name}
export BORG_PASSPHRASE='{{ job.password }}'
info "Starting backup"