at-confluence-backup/confluence.diy-restore.sh
2022-10-31 08:35:12 -07:00

68 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# -------------------------------------------------------------------------------------
# The DIY restore script.
#
# This script is invoked to perform a restore of a Bitbucket Server,
# or Bitbucket Data Center instance. It requires a properly configured
# bitbucket.diy-backup.vars.sh file, which can be copied from
# bitbucket.diy-backup.vars.sh.example and customized.
# -------------------------------------------------------------------------------------
# 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}/lvm.sh"
source "${SCRIPT_DIR}/dbase.sh"
source_archive_strategy
source_database_strategy
source_disk_strategy
# # Ensure we know which user:group things should be owned as
# if [ -z "${BITBUCKET_UID}" -o -z "${BITBUCKET_GID}" ]; then
# error "Both BITBUCKET_UID and BITBUCKET_GID must be set in '${BACKUP_VARS_FILE}'"
# bail "See 'bitbucket.diy-backup.vars.sh.example' 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