Skip to content

Commit 5de440a

Browse files
authored
Merge pull request #469 from github/enterprise-3.9-backport-408-zheng/6791-indicator
Backport 408 for 3.9: fix indicator when doing backup and restore
2 parents 1ccf30c + 16422d9 commit 5de440a

11 files changed

+75
-12
lines changed

bin/ghe-backup

Lines changed: 26 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\"

bin/ghe-restore

Lines changed: 12 additions & 8 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
@@ -484,6 +487,7 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then
484487
log_info "Skipping MySQL restore."
485488
else
486489
log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..."
490+
increment-progress-total-count 2
487491
ghe-restore-mysql "$GHE_HOSTNAME" 1>&3
488492
fi
489493

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-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-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

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5
2929
if [ -z "$pages_paths" ]; then
3030
log_warn "Warning: Pages backup missing. Skipping ..."
3131
exit 0
32+
else
33+
increment-progress-total-count 5
3234
fi
3335

3436
# Perform a host-check and establish GHE_REMOTE_XXX variables.
@@ -125,6 +127,8 @@ bm_end "$(basename $0) - Processing routes"
125127
if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then
126128
log_warn "Warning: no routes found, skipping pages restore ..."
127129
exit 0
130+
else
131+
increment-progress-total-count 2
128132
fi
129133

130134
bm_start "$(basename $0) - Restoring pages"
@@ -154,6 +158,7 @@ if $CLUSTER; then
154158
chunks=\$(find $remote_tempdir/ -name chunk\*)
155159
parallel -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks
156160
EOF
161+
increment-progress-total-count 1
157162
bm_end "$(basename $0) - Finalizing routes"
158163
fi
159164

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ network_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mi
3030
if [ -z "$network_paths" ]; then
3131
log_warn "Warning: Repositories backup missing. Skipping ..."
3232
exit 0
33+
else
34+
increment-progress-total-count 5
3335
fi
3436

3537
# Perform a host-check and establish GHE_REMOTE_XXX variables.
@@ -142,6 +144,8 @@ bm_end "$(basename $0) - Processing routes"
142144
if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then
143145
log_warn "Warning: no routes found, skipping repositories restore ..."
144146
exit 0
147+
else
148+
increment-progress-total-count 3
145149
fi
146150

147151
# rsync all the repository networks to the git server where they belong.
@@ -190,6 +194,7 @@ if $CLUSTER; then
190194
chunks=\$(find $remote_tempdir/ -name chunk\*)
191195
parallel -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
192196
EOF
197+
increment-progress-total-count 1
193198
bm_end "$(basename $0) - Finalizing routes"
194199
fi
195200

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ gist_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mind
2929
if [ -z "$gist_paths" ]; then
3030
log_warn "Warning: Gist backup missing. Skipping ..."
3131
exit 0
32+
else
33+
increment-progress-total-count 5
3234
fi
3335

3436
# Perform a host-check and establish GHE_REMOTE_XXX variables.
@@ -128,6 +130,8 @@ bm_end "$(basename $0) - Processing routes"
128130
if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then
129131
log_warn "Warning: no routes found, skipping gists restore ..."
130132
exit 0
133+
else
134+
increment-progress-total-count 2
131135
fi
132136

133137
# rsync all the gist repositories
@@ -157,6 +161,7 @@ if $CLUSTER; then
157161
chunks=\$(find $remote_tempdir/ -name chunk\*)
158162
parallel -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks
159163
EOF
164+
increment-progress-total-count 1
160165
bm_end "$(basename $0) - Finalizing routes"
161166
fi
162167

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindept
3333
if [ -z "$storage_paths" ]; then
3434
log_warn "Warning: Storage backup missing. Skipping ..."
3535
exit 0
36+
else
37+
increment-progress-total-count 5
3638
fi
3739

3840
# Perform a host-check and establish GHE_REMOTE_XXX variables.
@@ -120,6 +122,8 @@ bm_end "$(basename $0) - Processing routes"
120122
if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then
121123
log_warn "Warning: no routes found, skipping storage restore ..."
122124
exit 0
125+
else
126+
increment-progress-total-count 2
123127
fi
124128

125129
# rsync all the objects to the storage server where they belong.
@@ -169,6 +173,7 @@ if $CLUSTER; then
169173
chunks=\$(find $remote_tempdir/ -name chunk\*)
170174
parallel -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks
171175
EOF
176+
increment-progress-total-count 1
172177
bm_end "$(basename $0) - Finalizing routes"
173178
fi
174179

0 commit comments

Comments
 (0)