Skip to content

Commit d280390

Browse files
authored
Merge branch 'master' into master
2 parents ca7f9f1 + cd2c89b commit d280390

Some content is hidden

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

47 files changed

+845
-370
lines changed

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint Code Base
2+
3+
on:
4+
pull_request:
5+
branches-ignore:
6+
- 'master'
7+
8+
jobs:
9+
build:
10+
name: Lint Code Base
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v2
15+
- name: Lint Code Base
16+
uses: docker://github/super-linter:v2.1.1
17+
env:
18+
VALIDATE_ALL_CODEBASE: false

.github/workflows/main.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test and build
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
os: ['ubuntu-latest', 'macos-latest']
10+
# os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest']
11+
fail-fast: false
12+
runs-on: ${{ matrix.os }}
13+
14+
steps:
15+
- name: Install Dependencies (Linux)
16+
run: |
17+
sudo apt-get update -y
18+
sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz
19+
wget "https://github.com/koalaman/shellcheck/releases/download/v0.7.0/shellcheck-v0.7.0.linux.x86_64.tar.xz"
20+
tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz"
21+
sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck
22+
if: matrix.os == 'ubuntu-latest'
23+
- name: Install Dependencies (macOS)
24+
run: |
25+
brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt
26+
brew unlink parallel
27+
brew install moreutils gawk
28+
if: matrix.os == 'macos-latest'
29+
- name: Get Sources
30+
uses: actions/checkout@v2
31+
- name: Test
32+
run: |
33+
export PATH="$PATH:/snap/bin"
34+
make test
35+
shell: bash
36+
- name: Build (Linux)
37+
run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc
38+
if: matrix.os == 'ubuntu-latest'

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ RUN apt-get -q -y update && \
77
ca-certificates \
88
ssh \
99
git \
10+
moreutils \
11+
gawk \
1012
&& rm -rf /var/lib/apt/lists/*
1113

1214
WORKDIR /backup-utils

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
This repository includes backup and recovery utilities for
44
[GitHub Enterprise Server][1].
55

6+
**UPDATE**: The new parallel backup and restore beta feature will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed.
7+
68
**Note**: the [GitHub Enterprise Server version requirements][2] have
79
changed starting with Backup Utilities v2.13.0, released on 27 March 2018.
810

RELEASING.md

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,39 @@ There is no need to align Backup Utilities patch releases with GitHub Enterprise
88

99
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+
Only repo administrator is allowed to run the release script, otherwise it will fail.
1212

13-
### Feature release:
13+
## Pre-release Actions
1414

15-
`.ghe backup-utils-release 2.13.0 2.11.0`
15+
Prior to making a release,
1616

17-
### Patch release:
17+
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+
- have a "bug", "enhancement" or "feature" label,
20+
- 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.
1822

19-
`.ghe backup-utils-release 2.13.1`
23+
## Automatic Process from chatops (internal to GitHub only)
24+
25+
Coming :soon:
2026

2127
## Automatic Process from CLI
2228

23-
1. Install the Debian `devscripts` package:
24-
`sudo apt-get install devscripts`
25-
2. Run...
26-
- Feature release:
29+
1. Install the Debian `devscripts` and `moreutils` packages:
30+
`sudo apt-get install devscripts moreutils`
31+
2. Generate a PAT through github.com with access to the `github/backup-utils` repository. This will be used for the `GH_RELEASE_TOKEN` environment variable in the next step.
32+
3. Run...
33+
- Feature release:
2734
`GH_AUTHOR="Bob Smith <[email protected]>" GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0`
28-
- Patch release:
35+
- Patch release:
2936
`GH_AUTHOR="Bob Smith <[email protected]>" GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.1`
3037

3138
## Manual Process
3239

3340
In the event you can't perform the automatic process, or a problem is encountered with the automatic process, these are the manual steps you need to perform for a release.
3441

35-
1. Install the Debian `devscripts` package:
36-
`sudo apt-get install devscripts`
42+
1. Install the Debian `devscripts` and `moreutils` packages:
43+
`sudo apt-get install devscripts moreutils`
3744
2. Add a new version and release notes to the `debian/changelog` file:
3845
`dch --newversion 2.13.0 --release-heuristic log`
3946
You can use `make pending-prs` to craft the release notes.
@@ -45,3 +52,13 @@ In the event you can't perform the automatic process, or a problem is encountere
4552
8. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages.
4653
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`
4754
9. Push the head of the release to the 'stable' branch.
55+
56+
## Post-release Actions
57+
58+
Immediately after making a release using one of the methods above, verify the release has succeeded by checking:
59+
60+
- latest release at https://github.com/github/backup-utils/releases is correct,
61+
- release at https://github.com/github/backup-utils/releases is linked to the vX.Y.Z tag,
62+
- release has the notes you expect to see,
63+
- asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities,
64+
- the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master.

backup.config-example

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ GHE_NUM_SNAPSHOTS=10
2323
#
2424
#GHE_RESTORE_HOST="github-standby.example.com"
2525

26+
# If set to 'yes', ghe-restore will omit the restore of audit logs.
27+
#
28+
#GHE_RESTORE_SKIP_AUDIT_LOGS=no
29+
2630
# When verbose output is enabled with `-v`, it's written to stdout by default. If
2731
# you'd prefer it to be written to a separate file, set this option.
2832
#
@@ -48,3 +52,28 @@ GHE_NUM_SNAPSHOTS=10
4852
#
4953
# WARNING: do not enable this, only useful for debugging/development
5054
#GHE_BACKUP_FSCK=no
55+
56+
# If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'.
57+
#
58+
# WARNING: this feature is in beta.
59+
#GHE_PARALLEL_ENABLED=yes
60+
61+
# Sets the maximum number of jobs to run in parallel. Defaults to the number
62+
# of available processing units on the machine.
63+
#
64+
# WARNING: this feature is in beta.
65+
#GHE_PARALLEL_MAX_JOBS=2
66+
67+
# Sets the maximum number of rsync jobs to run in parallel. Defaults to the
68+
# configured GHE_PARALLEL_MAX_JOBS, or the number of available processing
69+
# units on the machine.
70+
#
71+
# WARNING: this feature is in beta.
72+
# GHE_PARALLEL_RSYNC_MAX_JOBS=3
73+
74+
# When jobs are running in parallel wait as needed to avoid starting new jobs
75+
# when the system's load average is not below the specified percentage. Defaults to
76+
# unrestricted.
77+
#
78+
# WARNING: this feature is in beta.
79+
#GHE_PARALLEL_MAX_LOAD=50

bin/ghe-backup

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ done
4141
# shellcheck source=share/github-backup-utils/ghe-backup-config
4242
. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config"
4343

44+
# Check to make sure moreutils parallel is installed and working properly
45+
ghe_parallel_check
46+
4447
# Used to record failed backup steps
4548
failures=
49+
failures_file="$(mktemp -t backup-utils-backup-failures-XXXXXX)"
4650

4751
# CPU and IO throttling to keep backups from thrashing around.
4852
export GHE_NICE=${GHE_NICE:-"nice -n 19"}
@@ -100,6 +104,8 @@ cleanup () {
100104
fi
101105
fi
102106

107+
rm -rf "$failures_file"
108+
103109
# Cleanup SSH multiplexing
104110
ghe-ssh --clean
105111
}
@@ -174,36 +180,57 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar ||
174180
failures="$failures ssh-host-keys"
175181
bm_end "ghe-export-ssh-host-keys"
176182

177-
echo "Backing up MySQL database ..."
178-
bm_start "ghe-export-mysql"
179-
echo 'set -o pipefail; ghe-export-mysql | gzip' |
180-
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql"
181-
bm_end "ghe-export-mysql"
183+
if is_binary_backup_feature_on; then
184+
echo "Backing up MySQL database using binary backup strategy ..."
185+
else
186+
echo "Backing up MySQL database using logical backup strategy ..."
187+
fi
188+
ghe-backup-mysql || failures="$failures mysql"
182189

183-
echo "Backing up Redis database ..."
184-
ghe-backup-redis > redis.rdb || failures="$failures redis"
190+
commands=("
191+
echo \"Backing up Redis database ...\"
192+
ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"")
185193

186-
echo "Backing up audit log ..."
187-
ghe-backup-es-audit-log || failures="$failures audit-log"
194+
commands+=("
195+
echo \"Backing up audit log ...\"
196+
ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"")
188197

189-
echo "Backing up hookshot logs ..."
190-
ghe-backup-es-hookshot || failures="$failures hookshot"
198+
commands+=("
199+
echo \"Backing up hookshot logs ...\"
200+
ghe-backup-es-hookshot || printf %s \"hookshot \" >> \"$failures_file\"")
191201

192-
echo "Backing up Git repositories ..."
193-
ghe-backup-repositories || failures="$failures repositories"
202+
commands+=("
203+
echo \"Backing up Git repositories ...\"
204+
ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"")
194205

195-
echo "Backing up GitHub Pages ..."
196-
ghe-backup-pages || failures="$failures pages"
206+
commands+=("
207+
echo \"Backing up GitHub Pages artifacts ...\"
208+
ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"")
197209

198-
echo "Backing up storage data ..."
199-
ghe-backup-storage || failures="$failures storage"
210+
commands+=("
211+
echo \"Backing up storage data ...\"
212+
ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"")
200213

201-
echo "Backing up custom Git hooks ..."
202-
ghe-backup-git-hooks || failures="$failures git-hooks"
214+
commands+=("
215+
echo \"Backing up custom Git hooks ...\"
216+
ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"")
203217

204218
if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
205-
echo "Backing up Elasticsearch indices ..."
206-
ghe-backup-es-rsync || failures="$failures elasticsearch"
219+
commands+=("
220+
echo \"Backing up Elasticsearch indices ...\"
221+
ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"")
222+
fi
223+
224+
if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then
225+
$GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}"
226+
else
227+
for c in "${commands[@]}"; do
228+
eval "$c"
229+
done
230+
fi
231+
232+
if [ -s "$failures_file" ]; then
233+
failures="$failures $(cat "$failures_file")"
207234
fi
208235

209236
# git fsck repositories after the backup

bin/ghe-host-check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if [ $rc -ne 0 ]; then
8484
exit $rc
8585
fi
8686

87-
version=$(echo "$output" | sed -E -n 's/GitHub Enterprise( Server)? version (.*)/\2/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
@@ -106,14 +106,14 @@ 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
115115
# of GitHub Enterprise Server.
116-
supported_minimum_version="2.14.0"
116+
supported_minimum_version="2.19.0"
117117

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

0 commit comments

Comments
 (0)