From d1754bb5a6d1190d1f26c105ed20480939d88117 Mon Sep 17 00:00:00 2001 From: BallsOfSpaghetti <115404710+OpenSpaghettiSauce@users.noreply.github.com> Date: Sat, 26 Nov 2022 13:52:42 +0100 Subject: [PATCH] Fix restore for NODATE I tested it in Virtualbox with my own live server backups and it seemed to restore fine like this. I'm not sure if the help/explanation is enough, feel free to add more, change wording, etc. --- helper-scripts/backup_and_restore.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index 3b0d9a31..6d81fc49 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -23,6 +23,10 @@ if [[ ${1} == "help" ]]; then NODATE: Allows you to omit the date stamped folder. example: NODATE=1 backup_and_restore.sh backup all + + IMPORTANT: If you'd like to restore a NODATE backup, you have to + use NODATE=1 for restoring as well! Otherwise, Mailcow will only + look for timestamped folders, which you will not have. You can combine the variables as well. example: THREADS=4 NODATE=1 backup_and_restore.sh backup all @@ -367,10 +371,20 @@ if [[ ${1} == "backup" ]]; then elif [[ ${1} == "restore" ]]; then i=1 declare -A FOLDER_SELECTION - if [[ $(find ${BACKUP_LOCATION}/mailcow-* -maxdepth 1 -type d 2> /dev/null| wc -l) -lt 1 ]]; then - echo "Selected backup location has no subfolders" - exit 1 + + if [[ -z "${NODATE}" ]]; then + # No NODATE defined so restore normally + if [[ $(find ${BACKUP_LOCATION}/mailcow-* -maxdepth 1 -type d 2> /dev/null| wc -l) -lt 1 ]]; then + echo "Selected backup location has no timestamped subfolders" + exit 1 + fi + else + if [[ $(find ${BACKUP_LOCATION}/* -maxdepth 1 -type d 2> /dev/null| wc -l) -lt 1 ]]; then + echo "Selected backup location has no subfolders" + exit 1 + fi fi + for folder in $(ls -d ${BACKUP_LOCATION}/mailcow-*/); do echo "[ ${i} ] - ${folder}" FOLDER_SELECTION[${i}]="${folder}"