Skip to content

Commit 7c2021a

Browse files
committed
fix indicator when doing backup and restore
1 parent 5f40dc1 commit 7c2021a

11 files changed

+74
-11
lines changed

bin/ghe-backup

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,30 @@ export PROGRESS_TYPE="Backup"
5050
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
5151
export PROGRESS=0 # Used to track progress of backup
5252
echo "$PROGRESS" > /tmp/backup-utils-progress
53-
export PROGRESS_TOTAL=18 # Maximum number of steps in backup
5453

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

@@ -269,6 +291,7 @@ echo \"$cmd_title\"
269291
ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"")
270292

271293
if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
294+
increment-progress-total-count 1
272295
cmd_title=$(log_info "Backing up Elasticsearch indices ...")
273296
commands+=("
274297
echo \"$cmd_title\"

bin/ghe-restore

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,12 @@ 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
288285
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1))
289286
fi
@@ -305,14 +302,21 @@ 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+
echo "add setting"
308+
OPTIONAL_STEPS=$((OPTIONAL_STEPS + 3))
309+
fi
310+
311+
# Minimum number of steps is 7
312+
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7))
310313

311314
init-progress
312315
export PROGRESS_TYPE="Restore"
313316
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
314317
export PROGRESS=0 # Used to track progress of restore
315318
echo "$PROGRESS" > /tmp/backup-utils-progress
319+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
316320

317321
# Log restore start message locally and in /var/log/syslog on remote instance
318322
START_TIME=$(date +%s)
@@ -446,6 +450,7 @@ ghe-restore-column-encryption-keys "$GHE_HOSTNAME"
446450
# Always restore secret scanning encryption keys
447451
if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then
448452
log_info "Always restore secret scanning encryption keys on GHES verions 3.8.0+"
453+
increment-progress-total-count 1
449454
ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME"
450455
fi
451456

@@ -490,6 +495,7 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then
490495
log_info "Skipping MySQL restore."
491496
else
492497
log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..."
498+
increment-progress-total-count 2
493499
ghe-restore-mysql "$GHE_HOSTNAME" 1>&3
494500
fi
495501

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=$((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)