From 94dd2b6f0ecbb4e8c06e335e53c06ba3cdc9c4ba Mon Sep 17 00:00:00 2001 From: szaimen Date: Sun, 20 Dec 2020 02:41:48 +0100 Subject: [PATCH] backup viewer - work around issue with borg (#1733) Signed-off-by: szaimen --- not-supported/backup-viewer.sh | 45 ++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/not-supported/backup-viewer.sh b/not-supported/backup-viewer.sh index bab643e8..8ba2b1ed 100644 --- a/not-supported/backup-viewer.sh +++ b/not-supported/backup-viewer.sh @@ -139,15 +139,6 @@ then exit 1 fi -# Find out which one was mounted -if [ "$choice" = "$DAILY_BACKUP_TARGET" ] -then - BACKUP_MOUNTPOINT="$DAILY_BACKUP_MOUNTPOINT" -elif [ "$choice" = "$OFFSHORE_BACKUP_TARGET" ] -then - BACKUP_MOUNTPOINT="$OFFSHORE_BACKUP_MOUNTPOINT" -fi - # Check the mountpoint if mountpoint -q /tmp/borg then @@ -159,6 +150,26 @@ then fi fi +# Rename the snapshot to represent that the backup is locked +if ! lvrename /dev/ubuntu-vg/NcVM-snapshot /dev/ubuntu-vg/NcVM-snapshot-pending +then + msg_box "Could not rename the snapshot. Please reboot your server!" + exit 1 +fi + +# Find out which one was mounted +if [ "$choice" = "$DAILY_BACKUP_TARGET" ] +then + BACKUP_MOUNTPOINT="$DAILY_BACKUP_MOUNTPOINT" +elif [ "$choice" = "$OFFSHORE_BACKUP_TARGET" ] +then + BACKUP_MOUNTPOINT="$OFFSHORE_BACKUP_MOUNTPOINT" + # Work around issue with borg + # https://github.com/borgbackup/borg/issues/3428#issuecomment-380399036 + mv /root/.config/borg/security/ /root/.config/borg/security.bak + mv /root/.cache/borg/ /root/.cache/borg.bak +fi + # Mount the repository mount "$BACKUP_MOUNTPOINT" export BORG_PASSPHRASE="$ENCRYPTION_KEY" @@ -195,13 +206,6 @@ list_format=user user_format=full name | mtime:15 | size:15 | owner:12 | group:12 | perm:12 MC_INI -# Rename the snapshot to represent that the backup is locked -if ! lvrename /dev/ubuntu-vg/NcVM-snapshot /dev/ubuntu-vg/NcVM-snapshot-pending -then - msg_box "Could not rename the snapshot. Please reboot your server!" - exit 1 -fi - # Show Midnight commander if ! mc /tmp/borg then @@ -216,6 +220,15 @@ then exit 1 fi +# Restore original cache and security folder +if [ "$BACKUP_MOUNTPOINT" = "$OFFSHORE_BACKUP_MOUNTPOINT" ] +then + rm -r /root/.config/borg/security + mv /root/.config/borg/security.bak/ /root/.config/borg/security + rm -r /root/.cache/borg + mv /root/.cache/borg.bak/ /root/.cache/borg +fi + # Re-rename the snapshot to represent that it is done if ! lvrename /dev/ubuntu-vg/NcVM-snapshot-pending /dev/ubuntu-vg/NcVM-snapshot then