From fa4eb448985b0cbf8e4db0d6559f7cf362dc1bbb Mon Sep 17 00:00:00 2001 From: szaimen Date: Sat, 3 Sep 2022 15:43:40 +0200 Subject: [PATCH] Allow to choose a different backup location if the first backup fails Signed-off-by: szaimen --- Containers/borgbackup/backupscript.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Containers/borgbackup/backupscript.sh b/Containers/borgbackup/backupscript.sh index c6b07d17..286cfed1 100644 --- a/Containers/borgbackup/backupscript.sh +++ b/Containers/borgbackup/backupscript.sh @@ -87,10 +87,12 @@ if [ "$BORG_MODE" = backup ]; then # Don't initialize if already initialized if [ -f "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer/data/borg.config" ]; then echo "Cannot initialize a new repository as that was already done at least one time." + echo "If you still want to do so, you may delete the 'borg.config' file that is stored in the mastercontainer volume manually, which will allow you to initialize a new borg repository in the chosen directory." exit 1 fi echo "initializing repository..." + NEW_REPOSITORY=1 if ! borg init --debug --encryption=repokey-blake2 "$BORG_BACKUP_DIRECTORY"; then echo "Could not initialize borg repository." rm -f "$BORG_BACKUP_DIRECTORY/config" @@ -133,6 +135,10 @@ if [ "$BORG_MODE" = backup ]; then echo "Deleting the failed backup archive..." borg delete --stats --progress "$BORG_BACKUP_DIRECTORY::$CURRENT_DATE-nextcloud-aio" echo "Backup failed!" + if [ "$NEW_REPOSITORY" = 1 ]; then + echo "Deleting borg.config file so that you can choose a different location for the backup." + rm "/nextcloud_aio_volumes/nextcloud_aio_mastercontainer/data/borg.config" + fi exit 1 fi