Skip to content

Commit db8fdae

Browse files
committed
Fix track-progress while progress files are not set
1 parent 939854d commit db8fdae

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

bin/ghe-backup

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ cleanup () {
118118

119119
rm -rf "$failures_file"
120120
rm -f "${GHE_DATA_DIR}/in-progress-backup"
121+
rm -rf /tmp/backup-utils-progress/*
121122

122123
# Cleanup SSH multiplexing
123124
ghe-ssh --clean

bin/ghe-restore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ cleanup () {
139139
log_error "Failed to remove in-progress file" 1>&3
140140
fi
141141

142+
# Remove progress files
143+
rm -rf /tmp/backup-utils-progress/*
144+
142145
bm_end "$(basename $0)"
143146
}
144147

share/github-backup-utils/track-progress

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
#/ track-progress: track progress of backup or restore tasks
33

44
progress(){
5-
5+
## Those progress files should be created by init_progress function
6+
## If they are not present (e.g., individual script is being invoked directly),
7+
## we will not track progress
8+
if [ -f "/tmp/backup-utils-progress/progress" ] &&
9+
[ -f "/tmp/backup-utils-progress/total" ] &&
10+
[ -f "/tmp/backup-utils-progress/type" ]; then
611
PROGRESS=$(cat /tmp/backup-utils-progress/progress)
712
PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress/total)
813
PROGRESS_TYPE=$(cat /tmp/backup-utils-progress/type)
914
PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc)
1015
echo $((PROGRESS + 1)) > /tmp/backup-utils-progress/progress
1116
echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress/info
17+
fi
1218
}

0 commit comments

Comments
 (0)