-
Notifications
You must be signed in to change notification settings - Fork 2
/
bitbucket.diy-restore.sh
executable file
·71 lines (53 loc) · 2.04 KB
/
bitbucket.diy-restore.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/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"
if [ "${INSTANCE_TYPE}" = "bitbucket-mesh" ]; then
# Mesh nodes don't run with an external database, so it doesn't need to be restored
BACKUP_DATABASE_TYPE="none"
# Mesh nodes don't run with an external Elasticsearch instance configured, so it doesn't need to be restored
BACKUP_ELASTICSEARCH_TYPE="none"
fi
source_archive_strategy
source_database_strategy
source_disk_strategy
source_elasticsearch_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}"
prepare_restore_elasticsearch "${1}"
if [ -n "${BACKUP_ARCHIVE_TYPE}" ]; then
restore_archive
fi
info "Restoring disk (home directory and data stores) and database"
# Restore the filesystem
restore_disk "${1}"
# Restore the database
restore_db
# Restore Elasticsearch data
restore_elasticsearch
success "Successfully completed the restore of your ${PRODUCT} instance"
if [ -n "${FINAL_MESSAGE}" ]; then
echo "${FINAL_MESSAGE}"
fi