Skip to content

Commit a7b3949

Browse files
Steve CulverSteve Culver
authored andcommitted
Merge remote-tracking branch 'public/master' into sync-public-to-private
2 parents 7672e5b + d29bc68 commit a7b3949

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+816
-145
lines changed

.dockerignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
*
2-
!share/github-backup-utils/ghe-docker-init
1+
.git/
2+
.github/
3+
.gitattributes
4+
.gitignore

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ jobs:
66
build:
77
strategy:
88
matrix:
9-
os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest']
9+
os: ['ubuntu-20.04', 'ubuntu-18.04', 'macos-latest']
1010
fail-fast: false
1111
runs-on: ${{ matrix.os }}
1212
steps:
1313
- name: Install Dependencies (Linux)
1414
run: |
1515
sudo apt-get update -y
16-
sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz
16+
sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man
1717
wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz"
1818
tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz"
1919
sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck
2020
if: matrix.os != 'macos-latest'
2121
- name: Install Dependencies (macOS)
2222
run: |
2323
brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt
24-
brew unlink parallel
2524
brew install moreutils gawk
2625
if: matrix.os == 'macos-latest'
2726
- name: Get Sources

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ RUN apt-get -q -y update && \
1111
gawk \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14+
COPY ./ /backup-utils/
1415
WORKDIR /backup-utils
15-
ADD https://github.com/github/backup-utils/archive/stable.tar.gz /
16-
RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \
17-
rm -r /stable.tar.gz
1816

1917
RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init
2018

Dockerfile.alpine

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ RUN apk --update --no-cache add \
1111
procps \
1212
coreutils
1313

14+
COPY ./ /backup-utils/
1415
WORKDIR /backup-utils
15-
ADD https://github.com/github/backup-utils/archive/stable.tar.gz /
16-
RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \
17-
mv /usr/bin/gawk /usr/bin/awk && \
18-
rm -r /stable.tar.gz
1916

2017
RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init
2118

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ to your specific GitHub Enterprise Server setup or would like assistance with
5050
backup site setup or recovery, please contact our [Enterprise support team][3]
5151
instead.
5252

53-
[1]: https://enterprise.github.com
53+
[1]: https://github.com/enterprise
5454
[2]: docs/requirements.md#github-enterprise-version-requirements
55-
[3]: https://enterprise.github.com/support/
55+
[3]: https://support.github.com/

bin/ghe-host-check

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ port=$(ssh_port_part "$host")
5353
hostname=$(ssh_host_part "$host")
5454

5555
set +e
56+
# ghe-negotiate-version verifies if the target is a Github Enterprise Server instance
5657
output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1)
5758
rc=$?
5859
set -e
@@ -130,7 +131,7 @@ fi
130131

131132
# backup-utils 2.13 onwards limits support to the current and previous two releases
132133
# of GitHub Enterprise Server.
133-
supported_minimum_version="2.22.0"
134+
supported_minimum_version="3.2.0"
134135

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

bin/ghe-restore

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,43 @@ cleanup () {
9191
update_restore_status "$1"
9292
fi
9393

94+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
95+
echo "Restarting Actions after restore ..."
96+
# In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the
97+
# force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists
98+
# in the --help output
99+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start --help' | grep -q force ; then
100+
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start -f' 1>&3
101+
else
102+
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3
103+
fi
104+
fi
105+
94106
# Cleanup SSH multiplexing
95107
ghe-ssh --clean
96108
}
97109

110+
# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally.
111+
# shellcheck disable=SC2034
112+
cleanup_cluster_nodes() {
113+
uuid="$1"
114+
if [ -z "$uuid" ]; then
115+
echo "Node UUID required."
116+
exit 2
117+
fi
118+
119+
ghe-spokes server evacuate git-server-$uuid 'Removing replica'
120+
ghe-spokes server destroy git-server-$uuid
121+
122+
ghe-storage destroy-host storage-server-$uuid --force
123+
124+
ghe-dpages offline pages-server-$uuid
125+
ghe-dpages remove pages-server-$uuid
126+
127+
ghe-redis-cli del resque:queue:maint_git-server-$uuid
128+
ghe-redis-cli srem resque:queues maint_git-server-$uuid
129+
}
130+
98131
# Bring in the backup configuration
99132
# shellcheck source=share/github-backup-utils/ghe-backup-config
100133
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"
@@ -231,7 +264,11 @@ fi
231264
# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data.
232265
if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then
233266
if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
267+
# Get GHES release version in major.minor format
268+
RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2)
269+
234270
echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2
271+
echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2
235272
exit 1
236273
fi
237274
fi
@@ -327,6 +364,9 @@ else
327364
fi
328365

329366
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
367+
echo "Stopping Actions before restoring databases ..."
368+
ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3
369+
330370
echo "Restoring MSSQL databases ..."
331371
ghe-restore-mssql "$GHE_HOSTNAME" 1>&3
332372

@@ -426,6 +466,13 @@ elif $instance_configured; then
426466
ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3
427467
fi
428468

469+
# Clear GitHub Connect settings stored in the restored database.
470+
# This needs to happen after `ghe-config-apply` to ensure all migrations have run.
471+
if ! $RESTORE_SETTINGS; then
472+
echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" |
473+
ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3
474+
fi
475+
429476
# Start cron. Timerd will start automatically as part of the config run.
430477
echo "Starting cron ..."
431478
if $CLUSTER; then
@@ -451,7 +498,8 @@ if ! $CLUSTER && $instance_configured; then
451498
if [ -n "$other_nodes" ]; then
452499
echo "Cleaning up stale nodes ..."
453500
for uuid in $other_nodes; do
454-
ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3
501+
# shellcheck disable=SC2034
502+
echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3
455503
done
456504
fi
457505
fi

debian/changelog

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,128 @@
1+
github-backup-utils (3.4.0) UNRELEASED; urgency=medium
2+
3+
* Add anchor to usage doc for settings restore #865
4+
5+
-- Steve Culver <[email protected]> Tue, 15 Feb 2022 19:25:09 +0000
6+
7+
github-backup-utils (3.3.1) UNRELEASED; urgency=medium
8+
9+
* Fix compat issue with ghe-actions-start during maintenance mode #836
10+
11+
-- [email protected] Tue, 21 Dec 2021 23:38:01 +0000
12+
13+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
14+
15+
16+
-- [email protected] Wed, 08 Dec 2021 03:12:53 +0000
17+
18+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
19+
20+
21+
-- [email protected] Wed, 08 Dec 2021 03:10:21 +0000
22+
23+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
24+
25+
26+
-- [email protected] Wed, 08 Dec 2021 02:56:47 +0000
27+
28+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
29+
30+
31+
-- [email protected] Wed, 08 Dec 2021 02:51:06 +0000
32+
33+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
34+
35+
36+
-- [email protected] Wed, 08 Dec 2021 02:02:25 +0000
37+
38+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
39+
40+
41+
-- [email protected] Wed, 08 Dec 2021 01:56:26 +0000
42+
43+
github-backup-utils (3.3.0) UNRELEASED; urgency=medium
44+
45+
46+
-- [email protected] Wed, 08 Dec 2021 01:25:12 +0000
47+
48+
github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium
49+
50+
51+
-- Nick Iodice <[email protected]> Tue, 09 Nov 2021 19:56:08 +0000
52+
53+
github-backup-utils (3.2.0) UNRELEASED; urgency=medium
54+
55+
56+
-- Brett Westover <[email protected]> Tue, 28 Sep 2021 16:50:00 +0000
57+
58+
github-backup-utils (3.2.0.rc3) UNRELEASED; urgency=medium
59+
60+
* Move GitHub Connect reset to after ghe-config-apply #783
61+
62+
-- Brett Westover <[email protected]> Fri, 17 Sep 2021 00:44:59 +0000
63+
64+
github-backup-utils (3.2.0.rc1) UNRELEASED; urgency=medium
65+
66+
* Leaked host key check: Avoid false positives from FIPS mode #748
67+
* Always restore user-password-secrets #762
68+
* Make some of the actions setting best effort #767
69+
* Remove reference to `ghe-cluster-cleanup-nodes` #768
70+
* Stop/Restart Actions in ghe-restore #769
71+
* Clear GitHub Connect settings when not restoring settings #770
72+
* GitHub Connect Reset Issue #776
73+
74+
-- Brett Westover <[email protected]> Fri, 10 Sep 2021 20:10:07 +0000
75+
76+
github-backup-utils (3.2.0) UNRELEASED; urgency=medium
77+
78+
* Leaked host key check: Avoid false positives from FIPS mode #748
79+
* Always restore user-password-secrets #762
80+
* Make some of the actions setting best effort #767
81+
* Remove reference to `ghe-cluster-cleanup-nodes` #768
82+
* Stop/Restart Actions in ghe-restore #769
83+
* Clear GitHub Connect settings when not restoring settings #770
84+
85+
-- Brett Westover <[email protected]> Thu, 09 Sep 2021 16:42:24 +0000
86+
87+
github-backup-utils (3.1.0) UNRELEASED; urgency=medium
88+
89+
90+
-- Zachary Mark <[email protected]> Thu, 03 Jun 2021 16:55:16 +0000
91+
192
github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium
293

94+
[ Zachary Mark ]
395
* Update repository backups to use ghe-gc-* for lock file management #188
496
* A faster way to restore storage blobs (clusters) #212
597
* Bug fix: Be more specific in restore routes globbing #715
698
* fix(docker): add coreutils to get flags for date #717
799
* Add backup cadence variable to the appliance #719
8100
* Fix is_default_external_database_snapshot function #720
9101

102+
[ Hideki Yamane ]
103+
* debian/rules
104+
- Drop unnecessary build-indep:
105+
- Add manpages generation.
106+
* debian/changelog
107+
- Fix some lintian warnings for old entries.
108+
* debian/source/format
109+
- Upgrade to newer source format 3.0 (native).
110+
* debian/copyright
111+
- Format it as Machine-readable debian/copyright format 1.0
112+
- Add entries Twan Wolthof <[email protected]> and me for debian/* since
113+
enough code was written by non-github.com employees, at least.
114+
* debian/control
115+
- Update descriptions in debian/control
116+
- Fix "Architecture: all", instead of "any".
117+
- Declare its Homepage as https://github.com/github/backup-utils
118+
- Add Vcs-* metadata field.
119+
- Specify "Rules-Requires-Root: no"
120+
- Drop unnecessary "Build-Depends: devscripts"
121+
- Set Standards-Version: 4.5.1
122+
- Update Maintainer as Zachary Mark <[email protected]>
123+
* debian/{clean,manpages}
124+
- Add files to support manpages handles.
125+
10126
-- Zachary Mark <[email protected]> Thu, 06 May 2021 17:11:18 +0000
11127

12128
github-backup-utils (3.0.0) UNRELEASED; urgency=medium
@@ -37,7 +153,7 @@ github-backup-utils (2.22.0) UNRELEASED; urgency=medium
37153
* Add parallelized restore capability to ghe-restore-storage #635
38154
* Update backup-utils for new features in 2.22 #641
39155

40-
-- [email protected] Wed, 23 Sep 2020 15:48:54 +0000
156+
-- Hao Jiang <[email protected]> Wed, 23 Sep 2020 15:48:54 +0000
41157

42158
github-backup-utils (2.21.0) UNRELEASED; urgency=medium
43159

@@ -135,6 +251,7 @@ github-backup-utils (2.16.1) UNRELEASED; urgency=medium
135251

136252
github-backup-utils (2.16.0) UNRELEASED; urgency=medium
137253

254+
* (There was no descriptions)
138255

139256
-- Colin Seymour <[email protected]> Tue, 22 Jan 2019 20:25:34 +0000
140257

@@ -146,11 +263,13 @@ github-backup-utils (2.15.1) UNRELEASED; urgency=medium
146263

147264
github-backup-utils (2.15.0) UNRELEASED; urgency=medium
148265

266+
* (There was no descriptions)
149267

150268
-- Colin Seymour <[email protected]> Tue, 16 Oct 2018 16:40:03 +0000
151269

152270
github-backup-utils (2.15.0) UNRELEASED; urgency=medium
153271

272+
* (There was no descriptions)
154273

155274
-- Colin Seymour <[email protected]> Tue, 16 Oct 2018 16:07:36 +0000
156275

debian/clean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
debian/*.1

debian/control

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
Source: github-backup-utils
2-
Maintainer: Twan Wolthof <xeago@spotify.com>
2+
Maintainer: Zachary Mark <zachary-mark@github.com>
33
Section: misc
44
Priority: optional
5-
Standards-Version: 3.9.2
6-
Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4)
5+
Standards-Version: 4.5.1
6+
Build-Depends: debhelper (>= 9), git, moreutils, jq, rsync (>= 2.6.4), help2man,
7+
Homepage: https://github.com/github/backup-utils
8+
Vcs-Git: https://github.com/github/backup-utils.git
9+
Vcs-Browser: https://github.com/github/backup-utils
10+
Rules-Requires-Root: no
711

812
Package: github-backup-utils
9-
Architecture: any
13+
Architecture: all
1014
Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq, git
1115
Description: Backup and recovery utilities for GitHub Enterprise Server
1216
The backup utilities implement a number of advanced capabilities for backup
1317
hosts, built on top of the backup and restore features already included in
1418
GitHub Enterprise Server.
1519
.
1620
These advanced features include:
17-
.
18-
Complete GitHub Enterprise Server backup and recovery system via two simple
19-
utilities:
20-
`ghe-backup` and `ghe-restore`.
21-
Online backups. The GitHub appliance need not be put in maintenance mode for
22-
the duration of the backup run.
23-
Incremental backup of Git repository data. Only changes since the last
24-
snapshot are transferred, leading to faster backup runs and lower network
25-
bandwidth and machine utilization.
26-
Efficient snapshot storage. Only data added since the previous snapshot
27-
consumes new space on the backup host.
28-
Multiple backup snapshots with configurable retention periods.
29-
Backup commands run under the lowest CPU/IO priority on the GitHub appliance,
30-
reducing performance impact while backups are in progress.
31-
Runs under most Linux/Unix environments.
32-
MIT licensed, open source software maintained by GitHub, Inc.
33-
21+
- Complete GitHub Enterprise Server backup and recovery system via two simple
22+
utilities: `ghe-backup` and `ghe-restore`.
23+
- Online backups. The GitHub appliance need not be put in maintenance mode for
24+
the duration of the backup run.
25+
- Incremental backup of Git repository data. Only changes since the last
26+
snapshot are transferred, leading to faster backup runs and lower network
27+
bandwidth and machine utilization.
28+
- Efficient snapshot storage. Only data added since the previous snapshot
29+
consumes new space on the backup host.
30+
- Multiple backup snapshots with configurable retention periods.
31+
- Backup runs under the lowest CPU/IO priority on the GitHub appliance,
32+
reducing performance impact while backups are in progress.

0 commit comments

Comments
 (0)