From 65f6943a4272055ee41dfeb0af2add6cbe75690b Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 14 Dec 2020 12:53:31 +0100 Subject: [PATCH] Improve mounting --- templates/restic_forget_snapshots.j2 | 28 +++++++++++++++++----------- vars/main.yml | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/templates/restic_forget_snapshots.j2 b/templates/restic_forget_snapshots.j2 index c503277..73b7892 100644 --- a/templates/restic_forget_snapshots.j2 +++ b/templates/restic_forget_snapshots.j2 @@ -49,22 +49,15 @@ set -euxo pipefail {%- endmacro %} {% if restic_archiver__mount_required %} -{% raw %} if mountpoint -q {{ restic_archiver__mount_disk }} then echo "{{ restic_archiver__mount_disk }} is mounted" else mount -a fi -{% endraw %} -{% else %} -{% macro validate_mounts() %} -# be excellent to each other! -{% endmacro %} {% endif %} # Settings for Server {{ repo['name'] | string }} -{{ validate_mounts }} export RESTIC_REPOSITORY="{{ repo['location'] }}" export RESTIC_PASSWORD='{{ repo['password'] | regex_replace('\'', '\'\\\'\'') }}' BACKUP_NAME="{{ repo.name }}" @@ -75,7 +68,6 @@ restic check {% if repo.archive|default(false) %} # ARCHIVE Settings for Server "{{ repo['name'] | string }}" -{{ validate_mounts }} export RESTIC_REPOSITORY="{{ repo['archive_location'] }}" export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}' export RESTIC_REPOSITORY2="{{ repo['location'] }}" @@ -87,8 +79,15 @@ if ([ -z "$(restic cat config)" ]) 2>/dev/null; then restic init --copy-chunker-params fi +{% if restic_archiver__mount_required %} +if mountpoint -q {{ restic_archiver__mount_disk }} +then + echo "{{ restic_archiver__mount_disk }} is mounted" +else + mount -a +fi +{% endif %} # ARCHIVE Settings for Server "{{ repo['name'] | string }}" -{{ validate_mounts }} export RESTIC_REPOSITORY2="{{ repo['archive_location'] }}" export RESTIC_PASSWORD2='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}' export RESTIC_REPOSITORY="{{ repo['location'] }}" @@ -99,8 +98,15 @@ restic copy {% if repo.archive_cleanup %} +{% if restic_archiver__mount_required %} +if mountpoint -q {{ restic_archiver__mount_disk }} +then + echo "{{ restic_archiver__mount_disk }} is mounted" +else + mount -a +fi +{% endif %} # ARCHIVE CLEANUP Settings for Server "{{ repo['name'] | string }}" -{{ validate_mounts }} export RESTIC_REPOSITORY="{{ repo['archive_location'] }}" export RESTIC_PASSWORD='{{ repo['archive_password'] | regex_replace('\'', '\'\\\'\'') }}' BACKUP_NAME="{{ repo.name }}_archive" @@ -115,5 +121,5 @@ restic check sync {% if restic_archiver__umount_after_usage %} -umount restic_archiver__mount_disk +umount {{ restic_archiver__mount_disk }} {% endif %} diff --git a/vars/main.yml b/vars/main.yml index 72c2721..eab56c2 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 26 # should be over ninethousand +playbook_version_number: 27 # should be over ninethousand playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'