Skip to content

Commit

Permalink
Merge branch 'master' into lildude/enhance-release-procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
lildude authored May 23, 2019
2 parents 39a13b6 + 138de17 commit 2c85be2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bin/ghe-host-check
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then
if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then
echo "Error: high availability replica detected." 1>&2
echo "Backup Utilities should be used to backup from the primary node in" 1>&2
echo "high availability environments to ensure consistent and repliable backups." 1>&2
echo "high availability environments to ensure consistent and reliable backups." 1>&2
exit 1
fi
fi
Expand Down
4 changes: 2 additions & 2 deletions bin/ghe-restore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ while true; do
;;
*)
if [ -n "$1" ]; then
GHE_RESTORE_HOST="$1"
GHE_RESTORE_HOST_OPT="$1"
shift
else
break
Expand All @@ -86,7 +86,7 @@ cleanup () {
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"

# Grab the host arg
GHE_HOSTNAME="$GHE_RESTORE_HOST"
GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}"

# Hostname without any port suffix
hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :)
Expand Down
36 changes: 35 additions & 1 deletion test/test-ghe-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,40 @@ begin_test "ghe-restore into unconfigured vm"
)
end_test

begin_test "ghe-restore with host arg and config value"
(
set -e
rm -rf "$GHE_REMOTE_ROOT_DIR"
setup_remote_metadata

# set as configured, enable maintenance mode and create required directories
setup_maintenance_mode "configured"

# set restore host environ var (which we shouldn't see)
GHE_RESTORE_HOST="broken.config.restore.host"
export GHE_RESTORE_HOST

# set restore host config var (which we shouldn't see)
GHE_BACKUP_CONFIG_TEMP="${GHE_BACKUP_CONFIG}.temp"
cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP"
echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP"
GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP"
export GHE_BACKUP_CONFIG

# run it
output="$(ghe-restore -f localhost)" || false

# clean up the config file
rm "$GHE_BACKUP_CONFIG_TEMP"

# verify host arg overrides configured restore host
echo "$output" | grep -q 'Connect localhost:22 OK'

# Verify all the data we've restored is as expected
verify_all_restored_data
)
end_test

begin_test "ghe-restore with host arg"
(
set -e
Expand All @@ -198,7 +232,7 @@ begin_test "ghe-restore with host arg"
setup_maintenance_mode "configured"

# set restore host environ var
GHE_RESTORE_HOST=127.0.0.1
GHE_RESTORE_HOST="broken.environ.restore.host"
export GHE_RESTORE_HOST

# run it
Expand Down

0 comments on commit 2c85be2

Please sign in to comment.