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 enabled: true
run_user: dkron run_user: dkron
working_dir: /opt/borg working_dir: /opt/borg
default_dirs:
- bin
- logs
- scripts
pip_pkgs: pip_pkgs:
- borgbackup - borgbackup
- llfuse - llfuse

View File

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

View File

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

View File

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