[Helper] Allow to run backup script everywhere

master
andryyy 2020-10-03 11:11:48 +02:00
parent 4234cc027b
commit d3a14f397c
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
1 changed files with 8 additions and 2 deletions

View File

@ -51,12 +51,18 @@ fi
BACKUP_LOCATION=$(echo ${BACKUP_LOCATION} | sed 's#/$##') BACKUP_LOCATION=$(echo ${BACKUP_LOCATION} | sed 's#/$##')
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COMPOSE_FILE=${SCRIPT_DIR}/../docker-compose.yml COMPOSE_FILE=${SCRIPT_DIR}/../docker-compose.yml
ENV_FILE=${SCRIPT_DIR}/../.env
if [ ! -f ${COMPOSE_FILE} ]; then if [ ! -f ${COMPOSE_FILE} ]; then
echo "Compose file not found" echo "Compose file not found"
exit 1 exit 1
fi fi
if [ ! -f ${ENV_FILE} ]; then
echo "Environment file not found"
exit 1
fi
echo "Using ${BACKUP_LOCATION} as backup/restore location." echo "Using ${BACKUP_LOCATION} as backup/restore location."
echo echo
@ -219,7 +225,7 @@ function restore() {
continue continue
else else
echo "Stopping mailcow..." echo "Stopping mailcow..."
docker-compose down docker-compose -f ${COMPOSE_FILE} --env-file ${ENV_FILE} down
fi fi
#docker stop $(docker ps -qf name=mysql-mailcow) #docker stop $(docker ps -qf name=mysql-mailcow)
if [[ -d "${RESTORE_LOCATION}/mysql" ]]; then if [[ -d "${RESTORE_LOCATION}/mysql" ]]; then
@ -257,7 +263,7 @@ function restore() {
sed -i --follow-symlinks "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf sed -i --follow-symlinks "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf
source ${SCRIPT_DIR}/../mailcow.conf source ${SCRIPT_DIR}/../mailcow.conf
echo "Starting mailcow..." echo "Starting mailcow..."
docker-compose up -d docker-compose -f ${COMPOSE_FILE} --env-file ${ENV_FILE} up -d
#docker start $(docker ps -aqf name=mysql-mailcow) #docker start $(docker ps -aqf name=mysql-mailcow)
fi fi
;; ;;