Skip to content

Commit 71555d6

Browse files
authored
Merge branch 'enterprise-3.9-release' into enterprise-3.9-backport-351-backup-restore-secret-scanning-encryption-keys
2 parents f02815e + 5de440a commit 71555d6

17 files changed

+152
-53
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
2626
libssl-dev \
2727
git \
2828
jq \
29+
bc \
2930
curl \
3031
tar \
3132
gzip \
@@ -54,8 +55,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
5455
git \
5556
openssh-client \
5657
jq \
58+
bc \
5759
moreutils \
58-
gawk \
60+
gawk \
5961
ca-certificates \
6062
xxhash \
6163
&& rm -rf /var/lib/apt/lists/*

bin/ghe-backup

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,36 @@ export CALLING_SCRIPT="ghe-backup"
4646

4747
# Setup progress tracking
4848
init-progress
49+
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
50+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
4951
export PROGRESS_TYPE="Backup"
5052
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
5153
export PROGRESS=0 # Used to track progress of backup
5254
echo "$PROGRESS" > /tmp/backup-utils-progress
53-
export PROGRESS_TOTAL=18 # Maximum number of steps in backup
5455

56+
OPTIONAL_STEPS=0
57+
# Backup actions+mssql
58+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
59+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2))
60+
fi
61+
62+
# Backup fsck
63+
if [ "$GHE_BACKUP_FSCK" = "yes" ]; then
64+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
65+
fi
66+
67+
# Backup minio
68+
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
69+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
70+
fi
71+
72+
# Backup pages
73+
if [ "$GHE_BACKUP_PAGES" != "no" ]; then
74+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
75+
fi
76+
77+
PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
78+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
5579
# Check to make sure moreutils parallel is installed and working properly
5680
ghe_parallel_check
5781

@@ -269,6 +293,7 @@ echo \"$cmd_title\"
269293
ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"")
270294

271295
if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
296+
increment-progress-total-count 1
272297
cmd_title=$(log_info "Backing up Elasticsearch indices ...")
273298
commands+=("
274299
echo \"$cmd_title\"
@@ -303,6 +328,8 @@ if [ -z "$failures" ]; then
303328
ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current"
304329

305330
ghe-prune-snapshots
331+
else
332+
log_info "Skipping pruning snapshots, since some backups failed..."
306333
fi
307334

308335
END_TIME=$(date +%s)

bin/ghe-host-check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ fi
131131

132132
# backup-utils 2.13 onwards limits support to the current and previous two releases
133133
# of GitHub Enterprise Server.
134-
supported_minimum_version="3.6.0"
134+
supported_minimum_version="3.7.0"
135135

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

bin/ghe-restore

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,14 @@ fi
275275
# taking into account the options passed to the script and the appliance configuration
276276
# calculate restore steps
277277
OPTIONAL_STEPS=0
278-
# Cluster restores add an additional step
279-
if $CLUSTER ; then
280-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
281-
fi
278+
282279
# Restoring UUID
283280
if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then
284281
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
285282
fi
286-
# Restoring Actions
283+
# Restoring Actions + MSSQL
287284
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then
288-
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
285+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2))
289286
fi
290287
# Restoring minio
291288
if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then
@@ -305,10 +302,16 @@ fi
305302
if ! $CLUSTER && $instance_configured; then
306303
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
307304
fi
308-
# Maximum restore steps
309-
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 6))
305+
# Restoring settings + restore-chat-integration + restore-packages
306+
if $RESTORE_SETTINGS; then
307+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 3))
308+
fi
309+
310+
# Minimum number of steps is 7
311+
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7))
310312

311313
init-progress
314+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
312315
export PROGRESS_TYPE="Restore"
313316
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
314317
export PROGRESS=0 # Used to track progress of restore
@@ -490,6 +493,7 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then
490493
log_info "Skipping MySQL restore."
491494
else
492495
log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..."
496+
increment-progress-total-count 2
493497
ghe-restore-mysql "$GHE_HOSTNAME" 1>&3
494498
fi
495499

@@ -618,10 +622,10 @@ if $CLUSTER; then
618622
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3
619623
fi
620624
ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3
621-
bm_end "configure_cluster"
625+
bm_end "$(basename $0) - configure cluster"
622626
elif $instance_configured; then
623627
log_info "Configuring appliance ..."
624-
bm_start "configure_appliance"
628+
bm_start "$(basename $0) - configure appliance"
625629
if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then
626630
ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3
627631
elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then

share/github-backup-utils/ghe-backup-config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ init-progress() {
712712
rm -f /tmp/backup-utils-progress*
713713
}
714714

715+
#increase total count of progress
716+
increment-progress-total-count() {
717+
((PROGRESS_TOTAL += $1))
718+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
719+
}
720+
715721

716722

717723

share/github-backup-utils/ghe-backup-mssql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then
4747
fi
4848

4949
tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX)
50-
ssh_config_file_opt=
51-
opts=
50+
ssh_config_file_opt=()
51+
opts=()
5252

5353
isHA="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.ha" || true)"
5454

share/github-backup-utils/ghe-backup-pages

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if [ -d "$GHE_DATA_DIR/current/pages" ] && [ "$(ls -A $GHE_DATA_DIR/current/page
6363
link_dest="--link-dest=../../current/pages"
6464
fi
6565

66+
count=0
6667
for hostname in $hostnames; do
6768
bm_start "$(basename $0) - $hostname"
6869
echo 1>&3
@@ -82,6 +83,7 @@ for hostname in $hostnames; do
8283
"$GHE_SNAPSHOT_DIR/pages" 1>&3
8384
log_rsync "END: pages rsync" 1>&3
8485
bm_end "$(basename $0) - $hostname"
86+
count=$((count + 1))
8587
done
86-
88+
increment-progress-total-count $count
8789
bm_end "$(basename $0)"

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ bm_end "$(basename $0) - Processing routes"
144144
if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then
145145
log_warn "no routes found, skipping repositories backup ..."
146146
exit 0
147+
else
148+
increment-progress-total-count 3
147149
fi
148150

149151
# Transfer repository data from a GitHub instance to the current snapshot
@@ -377,7 +379,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then
377379
(cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes
378380

379381
git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance."
380-
382+
increment-progress-total-count 1
381383
bm_end "$(basename $0) - Verifying Routes"
382384
fi
383385

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,11 @@ backup-secret "password pepper" "password-pepper" "secrets.github.user-password-
7979
backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret"
8080
backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret"
8181

82-
# backup encryption keying material for GHES 3.7.0 onwards
82+
# backup encryption keying material and create backup value current encryption for GHES 3.7.0 onwards
83+
# this is for forwards compatibility with GHES 3.8.0 onwards
8384
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then
8485
backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material"
85-
fi
86-
87-
# backup current encryption key for GHES 3.8.0 onwards
88-
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then
89-
backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key"
86+
cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key"
9087
fi
9188

9289
backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key"

share/github-backup-utils/ghe-backup-storage

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ bm_end "$(basename $0) - Processing routes"
113113
if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then
114114
log_warn "no routes found, skipping storage backup ..."
115115
exit 0
116+
else
117+
increment-progress-total-count 2
116118
fi
117119

118120
# rsync all the storage objects
@@ -149,6 +151,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then
149151

150152
git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance."
151153

154+
increment-progress-total-count 1
152155
bm_end "$(basename $0) - Verifying Routes"
153156
fi
154157

0 commit comments

Comments
 (0)