2022-10-31 09:37:42 -07:00

65 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# -------------------------------------------------------------------------------------
# The DIY restore script.
#
# This script is invoked to perform a restore of a Confluence Backup.
# -------------------------------------------------------------------------------------
# Ensure the script terminates whenever a required operation encounters an error
set -e
SCRIPT_DIR=$(dirname "$0")
source "${SCRIPT_DIR}/utils.sh"
source "${SCRIPT_DIR}/common.sh"
source "${SCRIPT_DIR}/func.sh"
source "${SCRIPT_DIR}/vars.sh"
source "${SCRIPT_DIR}/disk-lvm.sh"
source "${SCRIPT_DIR}/database-postgresql.sh"
source_archive_strategy
source_database_strategy
source_disk_strategy
# # Ensure we know which user:group things should be owned as
# if [ -z "${CONFLUENCE_UID}" -o -z "${CONFLUENCE_GID}" ]; then
# error "Both CONFLUENCE_UID and CONFLUENCE_GID must be set in '${BACKUP_VARS_FILE}'"
# bail "See 'vars.sh' for the defaults."
# fi
check_command "jq"
##########################################################
# Prepare for restore process
if [ -n "${BACKUP_ARCHIVE_TYPE}" ]; then
prepare_restore_archive "${1}"
fi
info "Preparing for restore"
prepare_restore_disk "${1}"
prepare_restore_db "${1}"
copy_archive_to_tmp
if [ -n "${BACKUP_ARCHIVE_TYPE}" ]; then
restore_archive
fi
info "Restoring disk and database"
# Restore the filesystem
restore_disk "${1}"
# Restore the database
restore_db
success "Successfully completed the restore of your ${PRODUCT} instance"
if [ -n "${FINAL_MESSAGE}" ]; then
echo "${FINAL_MESSAGE}"
fi