Skip to content

Commit 4b9968c

Browse files
authored
Merge branch 'master' into lildude/docs-update-reorg
2 parents ef43b08 + b9a81ed commit 4b9968c

File tree

94 files changed

+1551
-3579
lines changed

Some content is hidden

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

94 files changed

+1551
-3579
lines changed

bin/ghe-backup

Lines changed: 17 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ mkdir -p "$GHE_SNAPSHOT_DIR"
5656
cd "$GHE_SNAPSHOT_DIR"
5757
touch "incomplete"
5858

59-
# This is toggled true once we've successfully re-enabled maintenance mode
60-
# on the remote appliance. This is used to avoid trying to re-enable in the exit
61-
# trap again on successful backup runs.
62-
GHE_MAINTENANCE_MODE_ENABLED=false
63-
6459
# To prevent multiple backup runs happening at the same time, we create a
6560
# in-progress file with the timestamp and pid of the backup process,
6661
# giving us a form of locking.
@@ -80,10 +75,6 @@ cleanup () {
8075
fi
8176
fi
8277

83-
if $GHE_MAINTENANCE_MODE_ENABLED; then
84-
ghe-maintenance-mode-disable "$GHE_HOSTNAME"
85-
fi
86-
8778
# Cleanup SSH multiplexing
8879
ghe-ssh --clean "$GHE_HOSTNAME"
8980
}
@@ -131,22 +122,14 @@ export GHE_BACKUP_STRATEGY=${GHE_BACKUP_STRATEGY:-$(ghe-backup-strategy)}
131122
# Record the strategy with the snapshot so we will know how to restore.
132123
echo "$GHE_BACKUP_STRATEGY" > strategy
133124

134-
# If we're using the tarball backup strategy, put the appliance in maintenance
135-
# mode and wait for all writing processes to bleed out.
136-
if [ "$GHE_BACKUP_STRATEGY" = "tarball" ]; then
137-
ghe-maintenance-mode-enable "$GHE_HOSTNAME"
138-
GHE_MAINTENANCE_MODE_ENABLED=true
139-
fi
140-
141125
# Create benchmark file
142126
bm_init > /dev/null
143127

144128
ghe-backup-store-version ||
145129
echo "Warning: storing backup-utils version remotely failed."
146130

147131
echo "Backing up GitHub settings ..."
148-
ghe-backup-settings ||
149-
failures="$failures settings"
132+
ghe-backup-settings || failures="$failures settings"
150133

151134
echo "Backing up SSH authorized keys ..."
152135
bm_start "ghe-export-authorized-keys"
@@ -163,98 +146,38 @@ bm_end "ghe-export-ssh-host-keys"
163146
echo "Backing up MySQL database ..."
164147
bm_start "ghe-export-mysql"
165148
echo 'set -o pipefail; ghe-export-mysql | gzip' |
166-
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz ||
167-
failures="$failures mysql"
149+
ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql"
168150
bm_end "ghe-export-mysql"
169151

170152
echo "Backing up Redis database ..."
171-
if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then
172-
ghe-backup-redis-cluster > redis.rdb ||
173-
failures="$failures redis"
174-
else
175-
ghe-backup-redis > redis.rdb ||
176-
failures="$failures redis"
177-
fi
153+
ghe-backup-redis > redis.rdb || failures="$failures redis"
178154

179-
if [ $GHE_VERSION_MAJOR -ge 2 ]; then
180-
echo "Backing up audit log ..."
181-
ghe-backup-es-audit-log ||
182-
failures="$failures audit-log"
155+
echo "Backing up audit log ..."
156+
ghe-backup-es-audit-log || failures="$failures audit-log"
183157

184-
echo "Backing up hookshot logs ..."
185-
ghe-backup-es-hookshot ||
186-
failures="$failures hookshot"
187-
fi
158+
echo "Backing up hookshot logs ..."
159+
ghe-backup-es-hookshot || failures="$failures hookshot"
188160

189161
echo "Backing up Git repositories ..."
190-
if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then
191-
if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/dgit-cluster-backup-routes ; then
192-
echo "* Using calculated routes method..."
193-
ghe-backup-repositories-cluster-ng || failures="$failures repositories"
194-
else
195-
echo "* Using legacy method. A faster backup method is available on enterprise 2.7 and up."
196-
ghe-backup-repositories-cluster || failures="$failures repositories"
197-
fi
198-
else
199-
ghe-backup-repositories-${GHE_BACKUP_STRATEGY} ||
200-
failures="$failures repositories"
201-
fi
162+
ghe-backup-repositories || failures="$failures repositories"
202163

203164
echo "Backing up GitHub Pages ..."
204-
ghe-backup-pages-${GHE_BACKUP_STRATEGY} ||
205-
failures="$failures pages"
206-
207-
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
208-
if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then
209-
echo "Backing up storage data ..."
210-
if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/storage-cluster-backup-routes; then
211-
ghe-backup-alambic-cluster-ng || failures="$failures alambic"
212-
else
213-
ghe-backup-alambic-cluster || failures="$failures alambic"
214-
fi
165+
ghe-backup-pages || failures="$failures pages"
215166

216-
echo "Backing up custom Git hooks ..."
217-
ghe-backup-git-hooks-cluster ||
218-
failures="$failures git-hooks"
219-
else
220-
echo "Backing up asset attachments ..."
221-
ghe-backup-userdata alambic_assets ||
222-
failures="$failures alambic_assets"
223-
224-
echo "Backing up storage data ..."
225-
ghe-backup-userdata storage ||
226-
failures="$failures storage"
227-
228-
echo "Backing up hook deliveries ..."
229-
ghe-backup-userdata hookshot ||
230-
failures="$failures hookshot"
231-
232-
echo "Backing up custom Git hooks ..."
233-
ghe-backup-userdata git-hooks/environments/tarballs ||
234-
failures="$failures git-hooks-environments"
235-
ghe-backup-userdata git-hooks/repos ||
236-
failures="$failures git-hooks-repos"
237-
fi
238-
fi
167+
echo "Backing up storage data ..."
168+
ghe-backup-storage || failures="$failures storage"
239169

240-
if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then
241-
echo "Backing up Elasticsearch indices ..."
242-
ghe-backup-es-${GHE_BACKUP_STRATEGY} ||
243-
failures="$failures elasticsearch"
244-
fi
170+
echo "Backing up custom Git hooks ..."
171+
ghe-backup-git-hooks || failures="$failures git-hooks"
245172

246-
# If we're using the tarball backup strategy, bring the appliance out of
247-
# maintenance mode now instead of waiting until after pruning stale snapshots.
248-
if $GHE_MAINTENANCE_MODE_ENABLED; then
249-
ghe-maintenance-mode-disable "$GHE_HOSTNAME" ||
250-
echo "Warning: Disabling maintenance mode on $GHE_HOSTNAME failed."
251-
GHE_MAINTENANCE_MODE_ENABLED=false
173+
if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
174+
echo "Backing up Elasticsearch indices ..."
175+
ghe-backup-es-rsync || failures="$failures elasticsearch"
252176
fi
253177

254178
# git fsck repositories after the backup
255179
if [ "$GHE_BACKUP_FSCK" = "yes" ]; then
256-
ghe-backup-fsck $GHE_SNAPSHOT_DIR ||
257-
failures="$failures fsck"
180+
ghe-backup-fsck $GHE_SNAPSHOT_DIR || failures="$failures fsck"
258181
fi
259182

260183
# If everything was successful, mark the snapshot as complete, update the

bin/ghe-host-check

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ hostname=$(ssh_host_part "$host")
5454
set +e
5555
output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1)
5656
rc=$?
57-
if [ $rc = 127 ]; then
58-
# ghe-negotiate-version not found, fallback to reading version file
59-
legacy_version_output="1"
60-
output=$(echo "cat \"$GHE_REMOTE_METADATA_FILE\" 2>/dev/null || exit 101" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1)
61-
rc=$?
62-
fi
6357
set -e
6458

6559
if [ $rc -ne 0 ]; then
@@ -89,15 +83,26 @@ if [ $rc -ne 0 ]; then
8983
exit $rc
9084
fi
9185

92-
if [ -z "$legacy_version_output" ]; then
93-
version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p')
94-
else
95-
version=$(echo "$output" | grep version | cut -d'"' -f4)
96-
fi
86+
version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p')
9787

9888
if [ -z "$version" ]; then
9989
echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2
10090
exit 2
10191
fi
10292

93+
# backup-utils 2.13 onwards limits support to the current and previous two releases
94+
# of GitHub Enterprise.
95+
supported_minimum_version="2.11.0"
96+
97+
if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then
98+
supported=1
99+
fi
100+
101+
if [ -z "$supported" ]; then
102+
echo "Error: unsupported release of GitHub Enterprise detected." 1>&2
103+
echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise v$supported_minimum_version or newer." 1>&2
104+
echo "Please update your GitHub Enterprise appliance or use an older version of Backup Utilities." 1>&2
105+
exit 1
106+
fi
107+
103108
echo "Connect $hostname:$port OK (v$version)"

0 commit comments

Comments
 (0)