Skip to content

Commit 4e981fe

Browse files
committed
Merge remote-tracking branch 'public/master' into merge-public-into-private
2 parents 4e4148a + c443bd8 commit 4e981fe

20 files changed

+324
-148
lines changed

Dockerfile.alpine

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ RUN apk --update --no-cache add \
88
git \
99
bash \
1010
gawk \
11-
procps
11+
procps \
12+
coreutils
1213

1314
WORKDIR /backup-utils
1415
ADD https://github.com/github/backup-utils/archive/stable.tar.gz /

RELEASING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ Only repo administrator is allowed to run the release script, otherwise it will
1414

1515
Prior to making a release,
1616

17+
1. Sync any changes that have been merged to backup-utils-private into this repository.
1718
1. Go through the list of open pull requests and merge any that are ready for merging.
18-
2. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes:
19+
1. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes:
1920
- have a "bug", "enhancement" or "feature" label,
2021
- have a title that clearly describes the changes in that pull request. Reword if necessary.
21-
3. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes.
22+
1. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes.
2223

2324
## Automatic Process from chatops (internal to GitHub only)
2425

@@ -62,3 +63,4 @@ Immediately after making a release using one of the methods above, verify the re
6263
- release has the notes you expect to see,
6364
- asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities,
6465
- the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master.
66+
- sync this repository to backup-utils-private

bin/ghe-host-check

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ set -e
1515

1616
while true; do
1717
case "$1" in
18-
-h|--help)
19-
export GHE_SHOW_HELP=true
20-
shift
21-
;;
22-
--version)
23-
export GHE_SHOW_VERSION=true
24-
shift
25-
;;
26-
-*)
27-
echo "Error: invalid argument: '$1'" 1>&2
28-
exit 1
29-
;;
30-
*)
31-
break
32-
;;
18+
-h | --help)
19+
export GHE_SHOW_HELP=true
20+
shift
21+
;;
22+
--version)
23+
export GHE_SHOW_VERSION=true
24+
shift
25+
;;
26+
-*)
27+
echo "Error: invalid argument: '$1'" 1>&2
28+
exit 1
29+
;;
30+
*)
31+
break
32+
;;
3333
esac
3434
done
3535

3636
# Bring in the backup configuration
3737
# shellcheck source=share/github-backup-utils/ghe-backup-config
38-
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"
38+
. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-backup-config"
3939

4040
# Use the host provided on the command line if provided, or fallback on the
4141
# $GHE_HOSTNAME configured in backup.config when not present.
@@ -59,31 +59,48 @@ set -e
5959

6060
if [ $rc -ne 0 ]; then
6161
case $rc in
62-
255)
63-
if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then
64-
exec "$(basename $0)" "$hostname:122"
65-
fi
66-
62+
255)
63+
if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then
64+
exec "$(basename $0)" "$hostname:122"
65+
fi
66+
67+
echo "$output" 1>&2
68+
echo "Error: ssh connection with '$host' failed" 1>&2
69+
echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2
70+
echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2
71+
;;
72+
101)
73+
echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2
74+
;;
75+
1)
76+
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then
77+
exec "$(basename $0)" "$hostname:122"
78+
else
6779
echo "$output" 1>&2
68-
echo "Error: ssh connection with '$host' failed" 1>&2
69-
echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2
70-
echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2
71-
;;
72-
101)
73-
echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2
74-
;;
75-
1)
76-
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then
77-
exec "$(basename $0)" "$hostname:122"
78-
else
79-
echo "$output" 1>&2
80-
fi
81-
;;
80+
fi
81+
;;
8282

8383
esac
8484
exit $rc
8585
fi
8686

87+
CLUSTER=false
88+
if ghe-ssh "$host" -- \
89+
"[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then
90+
CLUSTER=true
91+
fi
92+
93+
# ensure all nodes in the cluster are running the same version
94+
if "$CLUSTER"; then
95+
node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version)
96+
distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l)
97+
if [ "$distinct_versions" -ne 1 ]; then
98+
echo "$node_version_list" 1>&2
99+
echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2
100+
exit 1
101+
fi
102+
fi
103+
87104
version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}')
88105

89106
if [ -z "$version" ]; then
@@ -113,7 +130,7 @@ fi
113130

114131
# backup-utils 2.13 onwards limits support to the current and previous two releases
115132
# of GitHub Enterprise Server.
116-
supported_minimum_version="2.19.0"
133+
supported_minimum_version="2.21.0"
117134

118135
if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then
119136
supported=1

bin/ghe-restore

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,32 @@ if $CLUSTER; then
249249
ghe_verbose "* Warning: Failed to stop cron on one or more nodes"
250250
fi
251251

252-
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then
253-
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
252+
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
253+
if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then
254+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then
255+
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
256+
fi
257+
fi
258+
else
259+
if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then
260+
ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes"
261+
fi
254262
fi
255263
else
256264
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then
257265
ghe_verbose "* Warning: Failed to stop cron"
258266
fi
259267

260-
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then
261-
ghe_verbose "* Warning: Failed to stop github-timerd"
268+
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
269+
if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then
270+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then
271+
ghe_verbose "* Warning: Failed to stop github-timerd"
272+
fi
273+
fi
274+
else
275+
if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then
276+
ghe_verbose "* Warning: Failed to stop github-timerd"
277+
fi
262278
fi
263279
fi
264280

@@ -392,9 +408,19 @@ echo "sudo restart -q memcached 2>/dev/null || true" |
392408
# config run to perform data migrations.
393409
if $CLUSTER; then
394410
echo "Configuring cluster ..."
411+
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
412+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3
413+
elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then
414+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3
415+
fi
395416
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3
396417
elif $instance_configured; then
397418
echo "Configuring appliance ..."
419+
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
420+
ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3
421+
elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then
422+
ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3
423+
fi
398424
ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3
399425
fi
400426

debian/changelog

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
github-backup-utils (3.0.0) UNRELEASED; urgency=medium
2+
3+
* Fix restoring the password pepper for already configured instances #683
4+
5+
-- Michael Dang <[email protected]> Tue, 16 Feb 2021 22:32:25 +0000
6+
7+
github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium
8+
9+
* Cleanup nomad container when restore for 2.22 #670
10+
* Use ghe-cluster-nomad-cleanup for cluster mode #663
11+
* Only run ghe-nomad-cleanup in 3.0 #662
12+
* Revert backup-utils gitHub env and a few more fixes #661
13+
* Note how to test filesystem symlink / hardlink support #660
14+
* stop github-timerd based on its running environment #659
15+
* Backup and restore password pepper #656
16+
* github-env -> github-env-dispatch #654
17+
* Rename redis-cli to ghe-redis-cli #639
18+
19+
-- Michael Dang <[email protected]> Thu, 14 Jan 2021 21:17:53 +0000
20+
21+
github-backup-utils (2.22.0) UNRELEASED; urgency=medium
22+
23+
* Added basic timing around the ghe-restore process #625
24+
* Improve python3 & finding moreutils parallel #627
25+
* Turn off POSIX for ghe-backup-config #632
26+
* Add parallelized restore capability to ghe-restore-storage #635
27+
* Update backup-utils for new features in 2.22 #641
28+
29+
-- [email protected] Wed, 23 Sep 2020 15:48:54 +0000
30+
131
github-backup-utils (2.21.0) UNRELEASED; urgency=medium
232

333
* Introduce option to skip restoring of audit logs #596

docs/requirements.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Backup Utilities use [hard links][5] to store data efficiently, and the
2727
repositories on GitHub Enterprise Server use [symbolic links][6] so the backup snapshots
2828
must be written to a filesystem with support for symbolic and hard links.
2929

30+
To check if your filesystem supports creating hardlinks of symbolic links, you can run the following within your backup destination directory:
31+
32+
```bash
33+
touch file
34+
ln -s file symlink
35+
ln symlink hardlink
36+
ls -la
37+
```
38+
3039
Using a [case sensitive][7] file system is also required to avoid conflicts.
3140

3241
## GitHub Enterprise Server version requirements
@@ -52,6 +61,8 @@ snapshot of GitHub Enterprise Server 2.11, the target GitHub Enterprise Server a
5261
be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapshot from
5362
2.10 to 2.13, because that's three releases ahead.
5463

64+
**Note**: You _cannot_ restore a backup created from a newer verison of GitHub Enterprise Server to an older version. For example, an attempt to restore a snapshot of GitHub Enterprise Server 2.21 to a GitHub Enterprise Server 2.20 environment will fail with an error of `Error: Snapshot can not be restored to an older release of GitHub Enterprise Server.`.
65+
5566
[1]: https://www.gnu.org/software/bash/
5667
[2]: https://git-scm.com/
5768
[3]: https://www.openssh.com/
@@ -61,4 +72,4 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh
6172
[7]: https://en.wikipedia.org/wiki/Case_sensitivity
6273
[8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/
6374
[9]: https://joeyh.name/code/moreutils
64-
[10]: https://www.gnu.org/software/gawk
75+
[10]: https://www.gnu.org/software/gawk

script/release

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
22
# frozen_string_literal: true
33

4-
#/ Usage: release [--dry-run] <version> [min_version]
4+
#/ Usage: release [--dry-run] [--skip-version-bump-check] <version> [min_version]
55
#/
66
#/ Publish a backup-utils release:
77
#/ * Updates the package changelog
@@ -196,7 +196,7 @@ end
196196

197197
def bump_version(new_version, min_version = nil, path = 'share/github-backup-utils/version')
198198
current_version = Gem::Version.new(File.read(path).strip.chomp)
199-
if Gem::Version.new(new_version) < current_version
199+
if !@skip_version_bump_check && (Gem::Version.new(new_version) < current_version)
200200
raise "New version should be newer than #{current_version}"
201201
end
202202
File.open("#{path}.new", 'w') { |f| f.puts new_version }
@@ -338,6 +338,7 @@ if $PROGRAM_NAME == __FILE__
338338
begin
339339
args = ARGV.dup
340340
dry_run = false
341+
skip_version_bump_check = false
341342
if args.include?('--dry-run')
342343
dry_run = true
343344
args.delete '--dry-run'
@@ -348,7 +349,12 @@ if $PROGRAM_NAME == __FILE__
348349
args.delete '--no-warn'
349350
end
350351

351-
raise 'Usage: release [--dry-run] <version> [min_version]' if args.empty?
352+
if args.include?('--skip-version-bump-check')
353+
@skip_version_bump_check = true
354+
args.delete '--skip-version-bump-check'
355+
end
356+
357+
raise 'Usage: release [--dry-run] [--skip-version-bump-check] <version> [min_version]' if args.empty?
352358

353359
begin
354360
version = Gem::Version.new(args[0])

share/github-backup-utils/ghe-backup-settings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ backup-secret() {
4040
}
4141

4242
backup-secret "management console password" "manage-password" "secrets.manage"
43+
backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets"
4344

4445
# Backup external MySQL password if running external MySQL DB.
4546
if is_service_external 'mysql'; then

share/github-backup-utils/ghe-restore-mysql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ghe_remote_version_required "$GHE_HOSTNAME"
2727
export GHE_RESTORE_SNAPSHOT
2828

2929
# The directory holding the snapshot to restore
30-
snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
30+
GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
3131

3232
if is_external_database_snapshot; then
3333
if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then
@@ -40,7 +40,7 @@ if is_external_database_snapshot; then
4040
bm_end "$(basename $0)"
4141
exit 0
4242
else
43-
if is_binary_backup "$snapshot_dir"; then
43+
if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then
4444
echo "Error: Restore of a binary backup to appliance with an external database configured is not supported."
4545
echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT"
4646
exit 1
@@ -63,18 +63,22 @@ if is_external_database_snapshot; then
6363
fi
6464

6565
if is_binary_backup_feature_on; then
66+
# Always restore the password pepper here since it is tied to the MySQL data.
67+
restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets"
6668
# Feature "mysql.backup.binary" is on, which means new backup scripts are available
67-
if is_binary_backup "$snapshot_dir"; then
69+
if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then
6870
ghe-restore-mysql-binary $GHE_HOSTNAME
6971
else
7072
ghe-restore-mysql-logical $GHE_HOSTNAME
7173
fi
7274
else
7375
# We do not allow to restore binary backup without "mysql.backup.binary" set
74-
if is_binary_backup "$snapshot_dir"; then
76+
if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then
7577
echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2
7678
exit 2
7779
else
80+
# Always restore the password pepper here since it is tied to the MySQL data.
81+
restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets"
7882
if is_default_external_database_snapshot; then
7983
ghe-restore-mysql-logical $GHE_HOSTNAME
8084
else

share/github-backup-utils/ghe-restore-repositories

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ cat $tmp_list | ghe_debug
120120
bm_end "$(basename $0) - Transferring network list"
121121

122122
bm_start "$(basename $0) - Generating routes"
123-
echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
123+
echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash
124124
ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug
125125
bm_end "$(basename $0) - Generating routes"
126126

@@ -144,7 +144,7 @@ fi
144144
# One rsync invocation per server available.
145145
bm_start "$(basename $0) - Restoring repository networks"
146146
rsync_commands=()
147-
for file_list in $tempdir/*.rsync; do
147+
for file_list in $tempdir/git-server-*.rsync; do
148148
if $CLUSTER; then
149149
server=$(basename $file_list .rsync)
150150
else

0 commit comments

Comments
 (0)