From 3583b99f2e73f041d709bfa0c829feb9b0c95d3d Mon Sep 17 00:00:00 2001 From: L3D Date: Mon, 14 Dec 2020 15:08:37 +0100 Subject: [PATCH] restic pipefail pipeline and mounting --- templates/restic_forget_snapshots.j2 | 8 ++++++-- vars/main.yml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/restic_forget_snapshots.j2 b/templates/restic_forget_snapshots.j2 index 73b7892..379d669 100644 --- a/templates/restic_forget_snapshots.j2 +++ b/templates/restic_forget_snapshots.j2 @@ -1,8 +1,6 @@ #!/usr/bin/env bash # {{ ansible_managed }} # This file is to cleanup your backup archive and move some snapshots to a external storage. -set -euxo pipefail - {% for repo in restic_archiver__repos %} {# @@ -56,6 +54,7 @@ else mount -a fi {% endif %} +set -euxo pipefail # Settings for Server {{ repo['name'] | string }} export RESTIC_REPOSITORY="{{ repo['location'] }}" @@ -80,12 +79,14 @@ if ([ -z "$(restic cat config)" ]) 2>/dev/null; then fi {% if restic_archiver__mount_required %} +set +euxo pipefail if mountpoint -q {{ restic_archiver__mount_disk }} then echo "{{ restic_archiver__mount_disk }} is mounted" else mount -a fi +set -euxo pipefail {% endif %} # ARCHIVE Settings for Server "{{ repo['name'] | string }}" export RESTIC_REPOSITORY2="{{ repo['archive_location'] }}" @@ -99,12 +100,14 @@ restic copy {% if repo.archive_cleanup %} {% if restic_archiver__mount_required %} +set +euxo pipefail if mountpoint -q {{ restic_archiver__mount_disk }} then echo "{{ restic_archiver__mount_disk }} is mounted" else mount -a fi +set -euxo pipefail {% endif %} # ARCHIVE CLEANUP Settings for Server "{{ repo['name'] | string }}" export RESTIC_REPOSITORY="{{ repo['archive_location'] }}" @@ -120,6 +123,7 @@ restic check {% endfor %} sync +set +euxo pipefail {% if restic_archiver__umount_after_usage %} umount {{ restic_archiver__mount_disk }} {% endif %} diff --git a/vars/main.yml b/vars/main.yml index eab56c2..535cc6f 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 27 # should be over ninethousand +playbook_version_number: 28 # should be over ninethousand playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'