Skip to content

Commit b1c88f5

Browse files
committed
Add GHE_REMOTE_DATA_USER_DIR and dynamic version config support
1 parent e3b57e3 commit b1c88f5

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

bin/ghe-backup

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ echo "Starting backup of $host in snapshot $GHE_SNAPSHOT_TIMESTAMP"
7070
ghe_remote_version_required
7171
echo "$GHE_REMOTE_VERSION" > version
7272

73-
if [ "$GHE_VERSION_MAJOR" -gt 1 ] && [ "$GHE_REMOTE_DATA_DIR" = /data ]; then
74-
export GHE_REMOTE_DATA_DIR=/data/user
75-
export GHE_REMOTE_LICENSE_FILE=/data/enterprise/enterprise.ghl
76-
export GHE_REMOTE_METADATA_FILE=/data/enterprise/chef_metadata.json
77-
fi
78-
7973
# Determine whether to use the rsync or tarball backup strategy based on the
8074
# remote appliance version. The tarball strategy must be used with GitHub
8175
# Enterprise versions prior to 11.10.340 since rsync is not available.

bin/ghe-restore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ echo "Starting $GHE_BACKUP_STRATEGY restore of $host from snapshot $GHE_RESTORE_
5353
# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION.
5454
ghe_remote_version_required "$host"
5555

56-
if [ "$GHE_VERSION_MAJOR" -gt 1 ] && [ "$GHE_REMOTE_DATA_DIR" = /data ]; then
57-
export GHE_REMOTE_DATA_DIR=/data/user
58-
export GHE_REMOTE_LICENSE_FILE=/data/enterprise/enterprise.ghl
59-
export GHE_REMOTE_METADATA_FILE=/data/enterprise/chef_metadata.json
60-
fi
61-
6256
# Restore license file under versions >= 2.x. This is for automated restores of
6357
# newly provisioned VMs in internal GitHub test environments only currently.
6458
if [ "$GHE_VERSION_MAJOR" -gt 1 ] && ! ghe-ssh "$host" "test -f '$GHE_REMOTE_LICENSE_FILE'"; then

libexec/ghe-backup-config

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@ export GHE_SNAPSHOT_TIMESTAMP
6969
# all backups should be written for the current invocation.
7070
GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP"
7171

72-
# The root location of all persistent data stores on the remote side. This is
73-
# always "/data" for GitHub instances. Use of this variable allows
72+
# The root location of persistent data and applications on the remote side. This
73+
# is always "/data" for GitHub instances. Use of this variable allows
7474
# the location to be overridden in tests.
7575
: ${GHE_REMOTE_DATA_DIR:="/data"}
7676

77+
# The root location of user data stores such as git repositories, pages sites,
78+
# elasticsearch indices, etc. This is "/data" under 1.x filesystem layouts and
79+
# "/data/user" under the 2.x filesystem layout. The location is adjusted
80+
# dynamically in ghe_remote_version_config() immediately after obtaining the
81+
# remote version. Utilities that transfer data in and out of the appliance
82+
# should use this variable to ensure proper behavior under different versions.
83+
: ${GHE_REMOTE_DATA_USER_DIR:="$GHE_REMOTE_DATA_DIR"}
84+
7785
# The location of the license file on the remote side. This is always
7886
# "/data/enterprise/enterprise.ghl" for GitHub instances. Use of this variable
7987
# allows the location to be overridden in tests.
@@ -96,6 +104,21 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP"
96104
# Set "true" to get verbose logging of all ssh commands on stderr
97105
: ${GHE_VERBOSE_SSH:=false}
98106

107+
108+
###############################################################################
109+
### Dynamic remote version config
110+
111+
# Adjusts remote paths based on the version of the remote appliance. This is
112+
# called immediately after the remote version is obtained by
113+
# ghe_remote_version_required(). Child processes inherit the values set here.
114+
ghe_remote_version_config () {
115+
if [ "$GHE_VERSION_MAJOR" -gt 1 ]; then
116+
GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user"
117+
fi
118+
export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR
119+
export GHE_REMOTE_LICENSE_FILE GHE_REMOTE_METADATA_FILE
120+
}
121+
99122
###############################################################################
100123
### Utility functions
101124

@@ -138,6 +161,7 @@ ghe_remote_version_required () {
138161
export GHE_REMOTE_VERSION
139162

140163
ghe_parse_remote_version "$GHE_REMOTE_VERSION"
164+
ghe_remote_version_config "$GHE_REMOTE_VERSION"
141165
fi
142166
true
143167
}

0 commit comments

Comments
 (0)