From 752f2417de59f7992dea79ad5769e619358c2bb6 Mon Sep 17 00:00:00 2001 From: Timo Reymann Date: Sun, 8 Sep 2019 10:54:21 +0200 Subject: [PATCH 1/2] Resolve #2794 Add restore for 'all' --- helper-scripts/backup_and_restore.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index 5054d6ee..24ff5f5a 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -211,6 +211,9 @@ elif [[ ${1} == "restore" ]]; then echo "No datasets found" exit 1 fi + + echo "[ 0 ] all" + FILE_SELECTION[0]="vmail crypt rspamd postfix mysql redis" for file in $(ls -f "${FOLDER_SELECTION[${input_sel}]}"); do if [[ ${file} =~ vmail ]]; then echo "[ ${i} ] - Mail directory (/var/vmail)" @@ -240,7 +243,7 @@ elif [[ ${1} == "restore" ]]; then done echo input_sel=0 - while [[ ${input_sel} -lt 1 || ${input_sel} -gt ${i} ]]; do + while [[ ${input_sel} -lt 0 || ${input_sel} -gt ${i} ]]; do read -p "Select a dataset to restore: " input_sel done echo "Restoring ${FILE_SELECTION[${input_sel}]} from ${RESTORE_POINT}..." From 45aa7b45fc72e26ed9fefb2d94a917a6d3740b89 Mon Sep 17 00:00:00 2001 From: Timo Reymann Date: Sun, 8 Sep 2019 12:21:12 +0200 Subject: [PATCH 2/2] #2794 Make parts to restore depend on backup folder contents --- helper-scripts/backup_and_restore.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helper-scripts/backup_and_restore.sh b/helper-scripts/backup_and_restore.sh index 24ff5f5a..9c5c070a 100755 --- a/helper-scripts/backup_and_restore.sh +++ b/helper-scripts/backup_and_restore.sh @@ -213,7 +213,8 @@ elif [[ ${1} == "restore" ]]; then fi echo "[ 0 ] all" - FILE_SELECTION[0]="vmail crypt rspamd postfix mysql redis" + # find all files in folder with .tar.gz extension, print their base names, remove backup_, remove .tar, remove .gz + FILE_SELECTION[0]=$(find "${FOLDER_SELECTION[${input_sel}]}" -type f -name "*.tar.gz" -printf "%f\n" | sed 's/backup_*//' | sed 's/\.[^.]*$//' | sed 's/\.[^.]*$//') for file in $(ls -f "${FOLDER_SELECTION[${input_sel}]}"); do if [[ ${file} =~ vmail ]]; then echo "[ ${i} ] - Mail directory (/var/vmail)" @@ -242,7 +243,7 @@ elif [[ ${1} == "restore" ]]; then fi done echo - input_sel=0 + input_sel=-1 while [[ ${input_sel} -lt 0 || ${input_sel} -gt ${i} ]]; do read -p "Select a dataset to restore: " input_sel done