From 43702a70450dea5e72bd86960c75182154188e5b Mon Sep 17 00:00:00 2001 From: MrGeneration Date: Thu, 20 Aug 2020 15:33:20 +0200 Subject: [PATCH] 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 --- contrib/backup/functions | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/contrib/backup/functions b/contrib/backup/functions index 1a58a0d23..be19c4997 100644 --- a/contrib/backup/functions +++ b/contrib/backup/functions @@ -153,10 +153,10 @@ function stop_zammad () { } function restore_zammad () { - 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} + if ! command -v zammad > /dev/null; then + # See #3160 for the reasons of this :> + restore_files + fi if [ "${DB_ADAPTER}" == "postgresql" ]; then echo "# ... Dropping current database ${DB_NAME}" @@ -185,6 +185,18 @@ function restore_zammad () { 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} 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 () {