Skip to content

Commit 0bab374

Browse files
authored
Merge pull request #159 from github/snh-sync
Sync with public repository
2 parents a546fe2 + 219c96a commit 0bab374

40 files changed

+1005
-192
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
language: minimal
23
matrix:
34
include:
45
- os: osx

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# GitHub Enterprise Backup Utilities
1+
# GitHub Enterprise Server Backup Utilities
22

3-
This repository includes backup and recovery utilities for [GitHub Enterprise][1].
3+
This repository includes backup and recovery utilities for
4+
[GitHub Enterprise Server][1].
45

5-
**Note**: the [GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements) have
6+
**Note**: the [GitHub Enterprise Server version requirements][2] have
67
changed starting with Backup Utilities v2.13.0, released on 27 March 2018.
78

89
### Features
910

1011
Backup Utilities implement a number of advanced capabilities for backup
1112
hosts, built on top of the backup and restore features already included in
12-
GitHub Enterprise.
13+
GitHub Enterprise Server.
1314

14-
- Complete GitHub Enterprise backup and recovery system via two simple utilities:<br>
15-
`ghe-backup` and `ghe-restore`.
15+
- Complete GitHub Enterprise Server backup and recovery system via two simple
16+
utilities:<br>`ghe-backup` and `ghe-restore`.
1617
- Online backups. The GitHub appliance need not be put in maintenance mode for
1718
the duration of the backup run.
1819
- Incremental backup of Git repository data. Only changes since the last
@@ -31,7 +32,7 @@ GitHub Enterprise.
3132
- **[Requirements](docs/requirements.md)**
3233
- **[Backup host requirements](docs/requirements.md#backup-host-requirements)**
3334
- **[Storage requirements](docs/requirements.md#storage-requirements)**
34-
- **[GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements)**
35+
- **[GitHub Enterprise Server version requirements](docs/requirements.md#github-enterprise-version-requirements)**
3536
- **[Getting started](docs/getting-started.md)**
3637
- **[Using the backup and restore commands](docs/usage.md)**
3738
- **[Scheduling backups](docs/scheduling-backups.md)**
@@ -43,8 +44,10 @@ GitHub Enterprise.
4344

4445
If you find a bug or would like to request a feature in Backup Utilities, please
4546
open an issue or pull request on this repository. If you have a question related
46-
to your specific GitHub Enterprise setup or would like assistance with backup
47-
site setup or recovery, please contact our [Enterprise support team][2] instead.
47+
to your specific GitHub Enterprise Server setup or would like assistance with
48+
backup site setup or recovery, please contact our [Enterprise support team][3]
49+
instead.
4850

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

RELEASING.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
# Making a Backup Utilities release
22

3-
Starting with Backup Utilities v2.13.0, all major releases will follow GitHub Enterprise releases and the version support is inline with that of the [GitHub Enterprise upgrade requirements](https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/) and as such, support is limited to three versions of GitHub Enterprise: the version that corresponds with the version of Backup Utilities, and the two releases prior to it.
3+
Starting with Backup Utilities v2.13.0, all major releases will follow GitHub Enterprise Server releases and the version support is inline with that of the [GitHub Enterprise Server upgrade requirements](https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/) and as such, support is limited to three versions of GitHub Enterprise Server: the version that corresponds with the version of Backup Utilities, and the two releases prior to it.
44

55
For example, Backup Utilities 2.13.0 can be used to backup and restore all patch releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. Backup utilities 2.14.0 will be released when GitHub Enterprise 2.14.0 is released and will then be used to backup all releases of GitHub Enterprise from 2.12.0 to the latest patch release of GitHub Enterprise 2.14.
66

7-
There is no need to align Backup Utilities patch releases with GitHub Enterprise patch releases.
7+
There is no need to align Backup Utilities patch releases with GitHub Enterprise Server patch releases.
88

9-
When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise that that release supports.
9+
When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that that release supports.
1010

11-
## Automatic Process from chatops (internal to GitHub only) - Coming :soon:
11+
## Pre-release Actions
1212

13-
### Feature release:
13+
Prior to making a release,
1414

15-
`.ghe backup-utils-release 2.13.0 2.11.0`
15+
1. Go through the list of open pull requests and merge any that are ready for merging.
16+
2. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes:
17+
- have a "bug", "enhancement" or "feature" label,
18+
- have a title that clearly describes the changes in that pull request. Reword if necessary.
19+
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.
1620

17-
### Patch release:
21+
## Automatic Process from chatops (internal to GitHub only)
1822

19-
`.ghe backup-utils-release 2.13.1`
23+
Coming :soon:
2024

2125
## Automatic Process from CLI
2226

2327
1. Install the Debian `devscripts` package:
2428
`sudo apt-get install devscripts`
2529
2. Run...
26-
- Feature release:
30+
- Feature release:
2731
`GH_AUTHOR="Bob Smith <[email protected]>" GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0`
28-
- Patch release:
32+
- Patch release:
2933
`GH_AUTHOR="Bob Smith <[email protected]>" GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.1`
3034

3135
## Manual Process
@@ -45,3 +49,13 @@ In the event you can't perform the automatic process, or a problem is encountere
4549
8. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages.
4650
The dist tarball you should upload has the revision in the file name, i.e. something like `github-backup-utils-v2.13.0.tar.gz`
4751
9. Push the head of the release to the 'stable' branch.
52+
53+
## Post-release Actions
54+
55+
Immediately after making a release using one of the methods above, verify the release has succeeded by checking:
56+
57+
- latest release at https://github.com/github/backup-utils/releases is correct,
58+
- release at https://github.com/github/backup-utils/releases is linked to the vX.Y.Z tag,
59+
- release has the notes you expect to see,
60+
- asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities,
61+
- the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master.

backup.config-example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# GitHub Enterprise backup configuration file
1+
# GitHub Enterprise Server backup configuration file
22

3-
# The hostname of the GitHub Enterprise appliance to back up. The host
3+
# The hostname of the GitHub Enterprise Server appliance to back up. The host
44
# must be reachable via SSH from the backup host.
55
GHE_HOSTNAME="github.example.com"
66

bin/ghe-backup

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,25 @@ if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile
8181
fi
8282
rm -rf src dest1 dest2
8383

84+
# if we should use gitbackups to backup repositories
85+
should_use_gitbackups_for_repositories(){
86+
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups"
87+
}
88+
89+
# check that the appliance supports using gitbackups for repositories
90+
can_use_gitbackups_for_repositories(){
91+
ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/backup-repositories
92+
}
93+
94+
# Exit early if the appliance is missing script to backup repositories using gitbackups
95+
if should_use_gitbackups_for_repositories; then
96+
if ! can_use_gitbackups_for_repositories; then
97+
echo "Error: Configuration setting 'app.github.gitbackups' is enabled but this version of GHES cannot use gitbackups to back up repositories via 'ghe-backup'."
98+
echo "Disable configuration setting 'app.github.gitbackups' and re-run 'ghe-backup' to use rsync."
99+
exit 1
100+
fi
101+
fi
102+
84103
# To prevent multiple backup runs happening at the same time, we create a
85104
# in-progress file with the timestamp and pid of the backup process,
86105
# giving us a form of locking.
@@ -174,23 +193,36 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar ||
174193
failures="$failures ssh-host-keys"
175194
bm_end "ghe-export-ssh-host-keys"
176195

196+
# if we are going to take a binary backup
197+
is_binary_backup(){
198+
ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary"
199+
}
200+
177201
echo "Backing up MySQL database ..."
178202
bm_start "ghe-export-mysql"
179203
echo 'set -o pipefail; ghe-export-mysql | gzip' |
180204
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql"
205+
if is_binary_backup; then
206+
touch mysql-binary-backup-sentinel
207+
fi
181208
bm_end "ghe-export-mysql"
182209

183210
echo "Backing up Redis database ..."
184211
ghe-backup-redis > redis.rdb || failures="$failures redis"
185212

186213
echo "Backing up audit log ..."
187-
ghe-backup-es-audit-log || failures="$failures audit-log"
214+
ghe-backup-audit-log || failures="$failures audit-log"
188215

189216
echo "Backing up hookshot logs ..."
190217
ghe-backup-es-hookshot || failures="$failures hookshot"
191218

192-
echo "Backing up Git repositories ..."
193-
ghe-backup-repositories || failures="$failures repositories"
219+
if should_use_gitbackups_for_repositories && can_use_gitbackups_for_repositories; then
220+
echo "Backing up Git repositories using gitbackups ..."
221+
ghe-backup-repositories-gitbackups || failures="$failures repositories"
222+
else
223+
echo "Backing up Git repositories using rsync ..."
224+
ghe-backup-repositories-rsync || failures="$failures repositories"
225+
fi
194226

195227
echo "Backing up GitHub Pages ..."
196228
ghe-backup-pages || failures="$failures pages"

bin/ghe-host-check

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env bash
22
#/ Usage: ghe-host-check [-h] [--version] [<host>]
33
#/
4-
#/ Verify connectivity with the GitHub Enterprise host.
4+
#/ Verify connectivity with the GitHub Enterprise Server host.
55
#/
66
#/ OPTIONS:
77
#/ -h | --help Show this message.
88
#/ --version Display version information.
9-
#/ <host> The GitHub Enterprise host to check. When no <host> is
10-
#/ provided, the $GHE_HOSTNAME configured in backup.config
11-
#/ is assumed.
9+
#/ <host> The GitHub Enterprise Server host to check. When no
10+
#/ <host> is provided, the $GHE_HOSTNAME configured in
11+
#/ backup.config is assumed.
1212
#/
1313

1414
set -e
@@ -70,7 +70,7 @@ if [ $rc -ne 0 ]; then
7070
echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2
7171
;;
7272
101)
73-
echo "Error: couldn't read GitHub Enterprise fingerprint on '$host' or this isn't a GitHub appliance." 1>&2
73+
echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2
7474
;;
7575
1)
7676
if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then
@@ -84,20 +84,20 @@ if [ $rc -ne 0 ]; then
8484
exit $rc
8585
fi
8686

87-
version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p')
87+
version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}')
8888

8989
if [ -z "$version" ]; then
9090
echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2
9191
exit 2
9292
fi
9393

94-
# Block restoring snapshots to older releases of GitHub Enterprise
94+
# Block restoring snapshots to older releases of GitHub Enterprise Server
9595
if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then
9696
snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)
9797
# shellcheck disable=SC2046 # Word splitting is required to populate the variables
9898
read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version)
9999
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
100+
echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise Server." >&2
101101
exit 1
102102
fi
103103
fi
@@ -106,23 +106,23 @@ if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then
106106
if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then
107107
echo "Error: high availability replica detected." 1>&2
108108
echo "Backup Utilities should be used to backup from the primary node in" 1>&2
109-
echo "high availability environments to ensure consistent and repliable backups." 1>&2
109+
echo "high availability environments to ensure consistent and reliable backups." 1>&2
110110
exit 1
111111
fi
112112
fi
113113

114114
# backup-utils 2.13 onwards limits support to the current and previous two releases
115-
# of GitHub Enterprise.
116-
supported_minimum_version="2.11.0"
115+
# of GitHub Enterprise Server.
116+
supported_minimum_version="2.17.0"
117117

118118
if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then
119119
supported=1
120120
fi
121121

122122
if [ -z "$supported" ]; then
123-
echo "Error: unsupported release of GitHub Enterprise detected." 1>&2
124-
echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise v$supported_minimum_version or newer." 1>&2
125-
echo "Please update your GitHub Enterprise appliance or use an older version of Backup Utilities." 1>&2
123+
echo "Error: unsupported release of GitHub Enterprise Server detected." 1>&2
124+
echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise Server v$supported_minimum_version or newer." 1>&2
125+
echo "Please update your GitHub Enterprise Server appliance or use an older version of Backup Utilities." 1>&2
126126
exit 1
127127
fi
128128

bin/ghe-restore

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ while true; do
6262
exit 1
6363
;;
6464
*)
65-
break
65+
if [ -n "$1" ]; then
66+
GHE_RESTORE_HOST_OPT="$1"
67+
shift
68+
else
69+
break
70+
fi
6671
;;
6772
esac
6873
done
@@ -81,7 +86,7 @@ cleanup () {
8186
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"
8287

8388
# Grab the host arg
84-
GHE_HOSTNAME="${1:-$GHE_RESTORE_HOST}"
89+
GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}"
8590

8691
# Hostname without any port suffix
8792
hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :)
@@ -137,21 +142,6 @@ if ghe-ssh "$GHE_HOSTNAME" -- \
137142
exit 1
138143
fi
139144

140-
# Only allow restores of 2.9 and 2.10 snapshots that have run the audit log migration to 2.11 and above
141-
if ! $force; then
142-
snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version)
143-
snapshot_version_major=$(echo "${snapshot_instance_version#v}" | cut -f 1 -d .)
144-
snapshot_version_minor=$(echo "$snapshot_instance_version" | cut -f 2 -d .)
145-
if ! test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete && \
146-
[ "$snapshot_version_major" -eq 2 ] && [ "$snapshot_version_minor" -lt 11 ] && \
147-
[ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 11 ]; then
148-
echo "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" >&2
149-
echo " audit log migration, or from v2.11.0 or above." >&2
150-
echo "Please see https://git.io/v5rCE for the audit log migration procedure." >&2
151-
exit 1
152-
fi
153-
fi
154-
155145
# Prompt to verify the restore host given is correct. Restoring overwrites
156146
# important data on the destination appliance that cannot be recovered. This is
157147
# mostly to prevent accidents where the backup host is given to restore instead
@@ -311,8 +301,8 @@ fi
311301
# Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and
312302
# all releases of cluster
313303
if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then
314-
echo "Restoring Elasticsearch Audit logs ..."
315-
ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3
304+
echo "Restoring Audit logs ..."
305+
ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3
316306

317307
echo "Restoring hookshot logs ..."
318308
ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3

debian/changelog

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
1+
github-backup-utils (2.19.1) UNRELEASED; urgency=medium
2+
3+
* Cater for more explicit gist paths used in routes file #524
4+
* Suppress "*.rsync': No such file or directory" errors when no data to backup or restore #525
5+
6+
-- Colin Seymour <[email protected]> Wed, 11 Dec 2019 09:33:01 +0000
7+
8+
github-backup-utils (2.19.0) UNRELEASED; urgency=medium
9+
10+
* Remove temporary exclude file from the backup host not the target GHES appliance #516
11+
* Update Debian package depends to include git #520
12+
13+
-- Colin Seymour <[email protected]> Tue, 12 Nov 2019 18:57:12 +0000
14+
15+
github-backup-utils (2.18.0) UNRELEASED; urgency=medium
16+
17+
* Replace "sed -E" in ghe-host-check with a more portable solution #509
18+
19+
-- Colin Seymour <[email protected]> Tue, 20 Aug 2019 18:49:44 +0000
20+
21+
github-backup-utils (2.17.1) UNRELEASED; urgency=medium
22+
23+
* Redirect ghe-export-audit-logs stderr output unless using verbose output #497
24+
25+
-- Colin Seymour <[email protected]> Wed, 05 Jun 2019 08:43:25 +0000
26+
27+
github-backup-utils (2.17.0) UNRELEASED; urgency=medium
28+
29+
* Restore target is ignored when specified on the command line #476
30+
* Support incremental backups for MySQL-stored audit logs #485
31+
32+
-- Colin Seymour <[email protected]> Thu, 23 May 2019 08:20:15 +0000
33+
34+
github-backup-utils (2.16.1) UNRELEASED; urgency=medium
35+
36+
* Detect storage user on each cluster host being backed up or restored #472
37+
38+
-- Colin Seymour <[email protected]> Tue, 26 Feb 2019 16:37:04 +0000
39+
40+
github-backup-utils (2.16.0) UNRELEASED; urgency=medium
41+
42+
43+
-- Colin Seymour <[email protected]> Tue, 22 Jan 2019 20:25:34 +0000
44+
45+
github-backup-utils (2.15.1) UNRELEASED; urgency=medium
46+
47+
* Restoring to an un-configured appliance fails due to a missing license file #449
48+
49+
-- Colin Seymour <[email protected]> Tue, 13 Nov 2018 17:34:21 +0000
50+
51+
github-backup-utils (2.15.0) UNRELEASED; urgency=medium
52+
53+
54+
-- Colin Seymour <[email protected]> Tue, 16 Oct 2018 16:40:03 +0000
55+
56+
github-backup-utils (2.15.0) UNRELEASED; urgency=medium
57+
58+
59+
-- Colin Seymour <[email protected]> Tue, 16 Oct 2018 16:07:36 +0000
60+
161
github-backup-utils (2.14.3) UNRELEASED; urgency=medium
262

363
* Improve multi-platform detection of simultaneous ghe-backup runs #435

0 commit comments

Comments
 (0)