[Helper] backup fixes
parent
a71d991c12
commit
212c18fd08
|
@ -202,14 +202,24 @@ function restore() {
|
|||
;;
|
||||
mysql)
|
||||
SQLIMAGE=$(grep -iEo '(mysql|mariadb)\:.+' ${COMPOSE_FILE})
|
||||
read -p "mailcow will be stopped and the corresponding mailcow.conf file of the backup will be restored, do you want to proceed? [y|N] " MYSQL_STOP_MAILCOW
|
||||
if [[ ${MYSQL_STOP_MAILCOW,,} =~ ^(yes|y)$ ]]; then
|
||||
echo "Stopping mailcow..."
|
||||
docker-compose down
|
||||
if [[ -z "${SQLIMAGE}" ]]; then
|
||||
echo "Could not determine SQL image version, skipping restore..."
|
||||
shift
|
||||
continue
|
||||
elif [ ! -f "${RESTORE_LOCATION}/mailcow.conf" ]; then
|
||||
echo "Could not find the corresponding mailcow.conf in ${RESTORE_LOCATION}, skipping restore."
|
||||
echo "If you lost that file, copy the last working mailcow.conf file to ${RESTORE_LOCATION} and restart the restore process."
|
||||
shift
|
||||
continue
|
||||
else
|
||||
read -p "mailcow will be stopped and the currently active mailcow.conf will be modified to use the DB parameters found in ${RESTORE_LOCATION}/mailcow.conf - do you want to proceed? [Y|n] " MYSQL_STOP_MAILCOW
|
||||
if [[ ${MYSQL_STOP_MAILCOW,,} =~ ^(no|n|N)$ ]]; then
|
||||
echo "OK, skipped."
|
||||
shift
|
||||
continue
|
||||
else
|
||||
echo "Stopping mailcow..."
|
||||
docker-compose down
|
||||
fi
|
||||
#docker stop $(docker ps -qf name=mysql-mailcow)
|
||||
if [[ -d "${RESTORE_LOCATION}/mysql" ]]; then
|
||||
|
@ -231,12 +241,17 @@ function restore() {
|
|||
gunzip < backup/backup_mysql.gz | mysql -uroot && \
|
||||
mysql -uroot -e SHUTDOWN;"
|
||||
fi
|
||||
echo "Copying mailcow.conf..."
|
||||
mv mailcow.conf mailcow.conf_backup_$(date +"%Y-%m-%d-%H-%M-%S")
|
||||
cp ${RESTORE_LOCATION}/mailcow.conf mailcow.conf
|
||||
echo "Modifying mailcow.conf..."
|
||||
source ${RESTORE_LOCATION}/mailcow.conf
|
||||
sed -i "/DBNAME/c\DBNAME=${DBNAME}" ${SCRIPT_DIR}/../mailcow.conf
|
||||
sed -i "/DBUSER/c\DBUSER=${DBUSER}" ${SCRIPT_DIR}/../mailcow.conf
|
||||
sed -i "/DBPASS/c\DBPASS=${DBPASS}" ${SCRIPT_DIR}/../mailcow.conf
|
||||
sed -i "/DBROOT/c\DBROOT=${DBROOT}" ${SCRIPT_DIR}/../mailcow.conf
|
||||
source ${SCRIPT_DIR}/../mailcow.conf
|
||||
echo "Starting mailcow..."
|
||||
docker-compose up -d
|
||||
#docker start $(docker ps -aqf name=mysql-mailcow)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
|
|
Loading…
Reference in New Issue