Fixes #3160 - Backup script restoration order causes issues if version difference causes ruby version differences

This commit ensures that the restore script will restore the database **before** restoring the file system of Zammad.

This solves ruby errors for environments that don't have old ruby versions installed (because they shouldn't be required during restorations).

This commit provides a compromise and behaves the old way for docker and source code installations. This is because it may be a source code installation is restored right away and was not installed before.

Hints for this are prepared for the documentation over at: https://github.com/zammad/zammad-documentation/pull/140
This commit is contained in:
MrGeneration 2020-08-20 15:33:20 +02:00 committed by Thorsten Eckel
parent 8b70f5703c
commit 43702a7045

View file

@ -153,10 +153,10 @@ function stop_zammad () {
} }
function restore_zammad () { function restore_zammad () {
echo "# Restoring Files" if ! command -v zammad > /dev/null; then
tar -C / --overwrite -xzf ${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz # See #3160 for the reasons of this :>
echo "# Ensuring correct file rights ..." restore_files
chown -R zammad:zammad ${ZAMMAD_DIR} fi
if [ "${DB_ADAPTER}" == "postgresql" ]; then if [ "${DB_ADAPTER}" == "postgresql" ]; then
echo "# ... Dropping current database ${DB_NAME}" echo "# ... Dropping current database ${DB_NAME}"
@ -185,6 +185,18 @@ function restore_zammad () {
echo "# Restoring MySQL DB" echo "# Restoring MySQL DB"
zcat ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | mysql -u${DB_USER} -p${DB_PASS} ${DB_NAME} zcat ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | mysql -u${DB_USER} -p${DB_PASS} ${DB_NAME}
fi fi
if command -v zammad > /dev/null; then
# See #3160 for the reasons of this :>
restore_files
fi
}
function restore_files () {
echo "# Restoring Files"
tar -C / --overwrite -xzf ${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz
echo "# Ensuring correct file rights ..."
chown -R zammad:zammad ${ZAMMAD_DIR}
} }
function start_backup_message () { function start_backup_message () {