Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enhance backup script #4833

Open
wants to merge 5 commits into
base: staging
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions helper-scripts/backup_and_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down