From 4cf66ebec4368531be8dfc36cae6d88f5f3b5ade Mon Sep 17 00:00:00 2001 From: Martin Kennedy Date: Sun, 28 Aug 2022 16:19:51 -0400 Subject: [PATCH] fix: More tweaks to get snapshot-finding to work Grr! this is really frustrating. We need more "tracking" for the snapshot we created. --- templates/restic_script_Linux.j2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/restic_script_Linux.j2 b/templates/restic_script_Linux.j2 index 178a1cd..3177e5d 100644 --- a/templates/restic_script_Linux.j2 +++ b/templates/restic_script_Linux.j2 @@ -110,14 +110,16 @@ function cleanup_vol { [ -d "$path" ] || path="$(dirname "$path")" { - local source="$(findmnt -v -f -J -T ${path} | jq -r '.filesystems[0].source')" + local source="$(findmnt -v -J -T ${path} | jq -r '.filesystems[]|.source' | grep '_snap$')" + + if ! grep -q '_snap$' <<< $source; then + echo "Snapshot for ${path} could not be found (found: ${source}). Exiting!" && return 1; + fi + echo "Cleaning up mount ..." umount "${path}" echo "Cleaning up snapshot ..." - if ! grep -q '_snap$' <<< $source; then - echo "Snapshot for ${path} could not be found (found: ${source}). Exiting!" && return 1; - fi umount "${source}" lvremove -y "${source}"; }