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.
This commit is contained in:
BallsOfSpaghetti 2022-11-26 13:52:42 +01:00
parent 567ff84a25
commit d1754bb5a6
1 changed files with 17 additions and 3 deletions

View File

@ -24,6 +24,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}"