Skip to content

Commit a25c326

Browse files
committed
Merge branch 'master' into snh/es-cluster-restore
2 parents ad46659 + 7a7e1c3 commit a25c326

File tree

11 files changed

+135
-5
lines changed

11 files changed

+135
-5
lines changed

bin/ghe-backup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [ -f ../in-progress ]; then
6969
progress=$(cat ../in-progress)
7070
snapshot=$(echo "$progress" | cut -d ' ' -f 1)
7171
pid=$(echo "$progress" | cut -d ' ' -f 2)
72-
if ! ps -p $pid -o command= | grep ghe-backup; then
72+
if ! ps -p $pid | grep ghe-backup; then
7373
# We can safely remove in-progress, ghe-prune-snapshots
7474
# will clean up the failed backup.
7575
unlink ../in-progress

bin/ghe-restore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ if $cluster; then
109109
snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)
110110
if ! echo $snapshot_instance_version | \
111111
grep -Eq "v2\.[5-9]|v2\.[1-9][0-9]|v[3-9]|v[1-9][0-9]"; then
112-
echo "Error: Snapshot must be from GitHub Enterprise v2.5.0 or above to be restored"
112+
echo "Error: Snapshot must be from GitHub Enterprise v2.5.0 or above to be restored" >&2
113113
echo " into a cluster (detected $snapshot_instance_version). Aborting." >&2
114114
exit 1
115115
fi
@@ -123,6 +123,21 @@ if ghe-ssh "$GHE_HOSTNAME" -- \
123123
exit 1
124124
fi
125125

126+
# Only allow restores of 2.9 and 2.10 snapshots that have run the audit log migration to 2.11 and above
127+
if ! $force; then
128+
snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)
129+
snapshot_version_major=$(echo "${snapshot_instance_version#v}" | cut -f 1 -d .)
130+
snapshot_version_minor=$(echo "$snapshot_instance_version" | cut -f 2 -d .)
131+
if ! test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete && \
132+
[ "$snapshot_version_major" -eq 2 ] && [ "$snapshot_version_minor" -lt 11 ] && \
133+
[ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 11 ]; then
134+
echo "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" >&2
135+
echo " audit log migration, or from v2.11.0 or above." >&2
136+
echo "Please see https://git.io/v5rCE for the audit log migration procedure." >&2
137+
exit 1
138+
fi
139+
fi
140+
126141
# Prompt to verify the restore host given is correct. Restoring overwrites
127142
# important data on the destination appliance that cannot be recovered. This is
128143
# mostly to prevent accidents where the backup host is given to restore instead
@@ -339,6 +354,11 @@ else
339354
ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3
340355
fi
341356

357+
# Restore the audit log migration sentinel file, if it exists in the snapshot
358+
if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then
359+
ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"
360+
fi
361+
342362
# Restart an already running memcached to reset the cache after restore
343363
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
344364
echo "Restarting memcached ..." 1>&3

debian/changelog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
github-backup-utils (2.11.0) UNRELEASED; urgency=medium
2+
3+
* Use calculated routes when backing up storage data from a cluster #318
4+
* Add SSH multiplexing support #321
5+
* Optimise route generation and finalisation during cluster restores #322
6+
* Prefer the SSH port specified on the command line #324
7+
8+
-- Colin Seymour <[email protected]> Wed, 13 Sep 2017 16:31:20 +0000
9+
110
github-backup-utils (2.10.0) UNRELEASED; urgency=medium
211

312
* Include the user data directory in the benchmark name #311

script/cibuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ REMOTE_VERSIONS="
1111
2.0.0
1212
2.2.0
1313
2.5.0
14+
2.11.0
1415
"
1516

1617
# Enable verbose logging of ssh commands

share/github-backup-utils/ghe-backup-es-audit-log

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/audit_
3131
exit 1
3232
fi
3333

34+
# Determine if the audit log migration has occurred or is needed.
35+
if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -f /usr/local/share/enterprise/run-audit-log-transitions.sh' | ghe-ssh "$host" /bin/bash; then
36+
if echo 'set -o pipefail; echo n | /usr/local/share/enterprise/run-audit-log-transitions.sh > /dev/null 2>&1 && touch /data/user/common/es-scan-complete' | ghe-ssh "$host" /bin/bash; then
37+
touch $GHE_SNAPSHOT_DIR/es-scan-complete
38+
fi
39+
fi
40+
3441
current_index=audit_log-$(ghe-ssh "$host" 'date +"%Y-%m"')
3542

3643
for index in $indices; do

share/github-backup-utils/ghe-backup-es-rsync

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,9 @@ ghe-rsync -avz \
9696
"$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \
9797
"$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3
9898

99+
# "Backup" audit log migration sentinel file
100+
if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then
101+
touch $GHE_SNAPSHOT_DIR/es-scan-complete
102+
fi
103+
99104
bm_end "$(basename $0)"

share/github-backup-utils/ghe-ssh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then
5858
fi
5959

6060
if [ -z "$GHE_DISABLE_SSH_MUX" ]; then
61-
controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)"
61+
controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)"
6262
opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts"
6363
# Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988
6464
[ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true

share/github-backup-utils/ghe-ssh-config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}"
2525

2626
opts="$GHE_EXTRA_SSH_OPTS"
2727

28-
[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts"
28+
[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts"
2929

3030
for host in $hosts; do
3131
cat <<EOF

share/github-backup-utils/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.10.0
1+
2.11.0

test/test-ghe-backup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
4949

5050
# Create a fake UUID
5151
echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid"
52+
53+
# Create fake audit log migration sentinel file
54+
touch "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"
5255
fi
5356

5457
# Create some fake elasticsearch data in the remote data directory
@@ -154,6 +157,9 @@ begin_test "ghe-backup first snapshot"
154157

155158
# check that ca certificates were backed up
156159
[ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ]
160+
161+
# verify the audit log migration sentinel file has been created
162+
[ -f "$GHE_DATA_DIR/current/es-scan-complete" ]
157163
fi
158164

159165
# verify that ghe-backup wrote its version information to the host
@@ -241,6 +247,9 @@ begin_test "ghe-backup subsequent snapshot"
241247

242248
# check that ca certificates were backed up
243249
[ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ]
250+
251+
# verify the audit log migration sentinel file has been created
252+
[ -f "$GHE_DATA_DIR/current/es-scan-complete" ]
244253
fi
245254
)
246255
end_test
@@ -344,6 +353,9 @@ begin_test "ghe-backup with relative data dir path"
344353

345354
# check that ca certificates were backed up
346355
[ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ]
356+
357+
# verify the audit log migration sentinel file has been created
358+
[ -f "$GHE_DATA_DIR/current/es-scan-complete" ]
347359
fi
348360

349361
# verify that ghe-backup wrote its version information to the host

0 commit comments

Comments
 (0)