Skip to content

Commit a546fe2

Browse files
committed
Merge remote-tracking branch 'public/master'
2 parents cfdfb01 + 1864c58 commit a546fe2

33 files changed

+458
-57
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ matrix:
77
- brew install gnu-tar
88
- brew install moreutils
99
- brew install shellcheck
10+
- brew install jq
1011
script: make test
1112
- os: linux
1213
dist: trusty
@@ -21,4 +22,5 @@ matrix:
2122
- debhelper
2223
- moreutils
2324
- fakeroot
25+
- jq
2426
script: debuild -uc -us

bin/ghe-backup

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@ if [ -f ../in-progress ]; then
119119
progress=$(cat ../in-progress)
120120
snapshot=$(echo "$progress" | cut -d ' ' -f 1)
121121
pid=$(echo "$progress" | cut -d ' ' -f 2)
122-
if ! ps -p $pid | grep ghe-backup; then
122+
if ! ps -p "$pid" >/dev/null 2>&1; then
123123
# We can safely remove in-progress, ghe-prune-snapshots
124124
# will clean up the failed backup.
125125
unlink ../in-progress
126126
else
127-
echo "Error: backup process $pid of $GHE_HOSTNAME already in progress in snapshot $snapshot. Aborting." 1>&2
127+
echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2
128+
echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2
129+
echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2
128130
exit 1
129131
fi
130132
fi

bin/ghe-host-check

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ if [ -z "$version" ]; then
9191
exit 2
9292
fi
9393

94+
# Block restoring snapshots to older releases of GitHub Enterprise
95+
if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then
96+
snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)
97+
# shellcheck disable=SC2046 # Word splitting is required to populate the variables
98+
read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version)
99+
if [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version $snapshot_version_major.$snapshot_version_minor.0)" ]; then
100+
echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise." >&2
101+
exit 1
102+
fi
103+
fi
104+
94105
if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then
95106
if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then
96107
echo "Error: high availability replica detected." 1>&2

bin/ghe-restore

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then
258258
echo "Restoring UUID ..."
259259
cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" |
260260
ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null"
261-
fi
261+
ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true
262+
ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft"
263+
fi
262264

263265
echo "Restoring MySQL database ..."
264-
bm_start "ghe-import-mysql"
265-
gzip -dc "$GHE_RESTORE_SNAPSHOT_PATH/mysql.sql.gz" | ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-mysql'
266-
bm_end "ghe-import-mysql"
266+
ghe-restore-mysql "$GHE_HOSTNAME" 1>&3
267267

268268
echo "Restoring Redis database ..."
269269
bm_start "ghe-import-redis"
@@ -273,17 +273,21 @@ bm_end "ghe-import-redis"
273273
# Unified and enhanced restore method to 2.13.0 and newer
274274
if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; then
275275
echo "Restoring Git repositories ..."
276-
ghe-restore-repositories "$GHE_HOSTNAME" 1>&3
276+
ghe-restore-repositories "$GHE_HOSTNAME"
277277

278278
echo "Restoring Gists ..."
279-
ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3
279+
ghe-restore-repositories-gist "$GHE_HOSTNAME"
280+
281+
echo "Restoring GitHub Pages ..."
282+
ghe-restore-pages "$GHE_HOSTNAME" 1>&3
280283
else
281284
echo "Restoring Git repositories and Gists ..."
282285
ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3
286+
287+
echo "Restoring GitHub Pages ..."
288+
ghe-restore-pages-rsync "$GHE_HOSTNAME" 1>&3
283289
fi
284290

285-
echo "Restoring GitHub Pages ..."
286-
ghe-restore-pages "$GHE_HOSTNAME" 1>&3
287291

288292
echo "Restoring SSH authorized keys ..."
289293
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json" 1>&3
@@ -341,6 +345,23 @@ else
341345
fi
342346
fi
343347

348+
# Clean up all stale replicas on configured instances.
349+
if ! $CLUSTER && $instance_configured; then
350+
restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid)
351+
other_nodes=$(echo "
352+
set -o pipefail; \
353+
ghe-spokes server show --json \
354+
| jq -r '.[] | select(.host | contains(\"git-server\")).host' \
355+
| sed 's/^git-server-//g' \
356+
| ( grep -F -x -v \"$restored_uuid\" || true )" \
357+
| ghe-ssh "$GHE_HOSTNAME" -- /bin/bash)
358+
if [ -n "$other_nodes" ]; then
359+
echo "Cleaning up stale nodes ..."
360+
for uuid in $other_nodes; do
361+
ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3
362+
done
363+
fi
364+
fi
344365

345366
# Update the remote status to "complete". This has to happen before importing
346367
# ssh host keys because subsequent commands will fail due to the host key

debian/changelog

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
github-backup-utils (2.14.3) UNRELEASED; urgency=medium
2+
3+
* Improve multi-platform detection of simultaneous ghe-backup runs #435
4+
5+
-- Colin Seymour <[email protected]> Tue, 11 Sep 2018 17:03:42 +0000
6+
7+
github-backup-utils (2.14.2) UNRELEASED; urgency=medium
8+
9+
* Capture and display repository/gist warnings during cluster restore #423
10+
* Use remote tempdir when finalizing Pages routes #424
11+
* Use old rsync restore method for pages prior to 2.13 #426
12+
13+
-- Colin Seymour <[email protected]> Tue, 21 Aug 2018 13:57:20 +0000
14+
15+
github-backup-utils (2.14.1) UNRELEASED; urgency=medium
16+
17+
* Don't fail a backup if the Management Console password isn't set #416
18+
* Fix permissions issues when repeat restoring to configured cluster instance #417
19+
* Add missing dependencies to debian packaging #418
20+
* Prevent restoring snapshots to older releases #420
21+
22+
-- Colin Seymour <[email protected]> Tue, 07 Aug 2018 16:00:36 +0000
23+
24+
github-backup-utils (2.14.0) UNRELEASED; urgency=medium
25+
26+
* Disable pager and context when running git-diff #411
27+
* Optimise hookshot and audit log backups and restores and MySQL restores #413
28+
29+
-- Colin Seymour <[email protected]> Thu, 12 Jul 2018 15:11:11 +0000
30+
31+
github-backup-utils (2.13.2) UNRELEASED; urgency=medium
32+
33+
* Treat missing repository networks, gists, and storage objects as a non-critical error #386
34+
* Clean up stale HA nodes on restore #396
35+
* Cleanup all SSH muxes in a non blocking way #402
36+
* Raise an error if the current symlink doesn't exist when attempting to restore it #404
37+
38+
-- Colin Seymour <[email protected]> Fri, 22 Jun 2018 10:08:22 +0000
39+
140
github-backup-utils (2.13.1) UNRELEASED; urgency=medium
241

342
* Retry with the admin ssh port on network unreachable too. #377

debian/control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Maintainer: Twan Wolthof <[email protected]>
33
Section: misc
44
Priority: optional
55
Standards-Version: 3.9.2
6-
Build-Depends: debhelper (>= 9), git, devscripts
6+
Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq
77

88
Package: github-backup-utils
99
Architecture: any
10-
Depends: ${misc:Depends}, rsync (>= 2.6.4)
10+
Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq
1111
Description: Backup and recovery utilities for GitHub Enterprise
1212
The backup utilities implement a number of advanced capabilities for backup
1313
hosts, built on top of the backup and restore features already included in

docs/getting-started.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
backup and restore GitHub Enterprise 2.10 and earlier.
1313

1414
2. Copy the [`backup.config-example`][3] file to `backup.config` and modify as
15-
necessary. The `GHE_HOSTNAME` value must be set to the GitHub Enterprise
15+
necessary. The `GHE_HOSTNAME` value must be set to the primary GitHub Enterprise
1616
host name. Additional options are available and documented in the
1717
configuration file but none are required for basic backup functionality.
1818

19+
As the data on a High Availability replica may be in a transient state at the time of backup,
20+
Backup Utilities should not be used to backup data from a High Availability replica.
21+
1922
* Backup Utilities will attempt to load the backup configuration from the following
2023
locations, in this order:
2124

script/cibuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ set -e
77
# conditional logic based on the remote version. Running the suite against
88
# different major versions ensures we're covering these conditional paths.
99
REMOTE_VERSIONS="
10-
2.11.0
11-
2.13.0
10+
2.12.0
11+
2.14.0
1212
"
1313

1414
# Enable verbose logging of ssh commands

script/release

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ def bump_version(new_version, min_version = nil, path = 'share/github-backup-uti
205205
content = File.read('bin/ghe-host-check')
206206
new_content = content.gsub(/supported_minimum_version="[0-9]\.[0-9]+\.0"/, "supported_minimum_version=\"#{min_version}\"")
207207
File.open('bin/ghe-host-check', 'w') {|file| file.puts new_content }
208+
209+
content = File.read('test/testlib.sh')
210+
new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/,"GHE_TEST_REMOTE_VERSION:=#{new_version}")
211+
File.open('test/testlib.sh', 'w') {|file| file.puts new_content }
208212
end
209213
end
210214

@@ -384,6 +388,7 @@ if $PROGRAM_NAME == __FILE__
384388
puts `git diff --color`
385389
`git checkout -- share/github-backup-utils/version`
386390
`git checkout -- bin/ghe-host-check`
391+
`git checkout -- test/testlib.sh`
387392
exit
388393
end
389394

@@ -402,7 +407,8 @@ if $PROGRAM_NAME == __FILE__
402407

403408
puts 'Updating changelog...'
404409
update_changelog release_changes, DEB_PKG_NAME, version
405-
release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}"
410+
release_body = "Includes general improvements & bug fixes"
411+
release_body += " and support for GitHub Enterprise v#{version}" unless min_version.nil?
406412
release_changes.each do |c|
407413
release_body += "\n* #{c}"
408414
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fi
8080
# otherwise, redirect it to /dev/null. Write verbose output to fd 3.
8181
if [ -n "$GHE_VERBOSE" ]; then
8282
if [ -n "$GHE_VERBOSE_LOG" ]; then
83-
exec 3<> "$GHE_VERBOSE_LOG"
83+
exec 3>> "$GHE_VERBOSE_LOG"
8484
else
8585
exec 3>&1
8686
fi

0 commit comments

Comments
 (0)