Skip to content

Commit 1ea7ab8

Browse files
authored
Merge pull request #244 from github/cluster-restore-to-standalone
Prevent restoring a cluster snapshot to a standalone GHE appliance
2 parents b6df3f4 + 4982667 commit 1ea7ab8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

bin/ghe-restore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ if ghe-ssh "$GHE_HOSTNAME" -- \
105105
restore_settings=false
106106
fi
107107

108+
# Restoring a cluster backup to a standalone appliance is not supported
109+
if ! $cluster && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then
110+
echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \
111+
"to a standalone appliance. Aborting." >&2
112+
exit 1
113+
fi
114+
108115
# Figure out if we're restoring into a cluster with an unsupported snapshot
109116
if $cluster; then
110117
snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)

test/test-ghe-restore.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,30 @@ begin_test "ghe-restore with tarball strategy"
484484
echo "$output" | grep -q 'fake ghe-export-repositories data'
485485
)
486486
end_test
487+
488+
begin_test "ghe-restore cluster backup to non-cluster appliance"
489+
(
490+
set -e
491+
rm -rf "$GHE_REMOTE_ROOT_DIR"
492+
setup_remote_metadata
493+
494+
# create file used to determine if instance has been configured.
495+
if [ "$GHE_VERSION_MAJOR" -le 1 ]; then
496+
touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json"
497+
else
498+
touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured"
499+
fi
500+
501+
# create file used to determine if instance is in maintenance mode.
502+
mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system"
503+
touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html"
504+
505+
# Create fake remote repositories dir
506+
mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories"
507+
508+
echo "cluster" > "$GHE_DATA_DIR/current/strategy"
509+
! output=$(ghe-restore -v -f localhost 2>&1)
510+
511+
echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored"
512+
)
513+
end_test

0 commit comments

Comments
 (0)