File tree Expand file tree Collapse file tree 7 files changed +35
-19
lines changed
share/github-backup-utils Expand file tree Collapse file tree 7 files changed +35
-19
lines changed Original file line number Diff line number Diff line change @@ -163,11 +163,11 @@ echo "$GHE_REMOTE_VERSION" > version
163
163
# Setup progress tracking
164
164
init-progress
165
165
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
166
- echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress- total
166
+ echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress/ total
167
167
export PROGRESS_TYPE=" Backup"
168
- echo " $PROGRESS_TYPE " > /tmp/backup-utils-progress- type
168
+ echo " $PROGRESS_TYPE " > /tmp/backup-utils-progress/ type
169
169
export PROGRESS=0 # Used to track progress of backup
170
- echo " $PROGRESS " > /tmp/backup-utils-progress
170
+ echo " $PROGRESS " > /tmp/backup-utils-progress/progress
171
171
172
172
OPTIONAL_STEPS=0
173
173
# Backup actions+mssql
@@ -191,7 +191,7 @@ if [ "$GHE_BACKUP_PAGES" != "no" ]; then
191
191
fi
192
192
193
193
PROGRESS_TOTAL=$(( OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
194
- echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress- total
194
+ echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress/ total
195
195
196
196
# check that incremental settings are valid if set
197
197
is_inc=$( is_incremental_backup_feature_on)
Original file line number Diff line number Diff line change @@ -31,26 +31,26 @@ while true; do
31
31
done
32
32
33
33
check_for_progress_file () {
34
- if [ ! -f /tmp/backup-utils-progress- info ]; then
34
+ if [ ! -f /tmp/backup-utils-progress/ info ]; then
35
35
echo " No progress file found. Has a backup or restore been started?"
36
36
exit 1
37
37
fi
38
38
}
39
39
40
40
if [ -n " $ONCE " ]; then
41
41
check_for_progress_file
42
- cat /tmp/backup-utils-progress- info
42
+ cat /tmp/backup-utils-progress/ info
43
43
else
44
44
check_for_progress_file
45
45
clear
46
- cat /tmp/backup-utils-progress- info
46
+ cat /tmp/backup-utils-progress/ info
47
47
while true ; do
48
48
if read -r -t 1 -n 1; then
49
49
clear
50
50
exit ;
51
51
else
52
52
clear
53
- cat /tmp/backup-utils-progress- info
53
+ cat /tmp/backup-utils-progress/ info
54
54
fi
55
55
done
56
56
fi
Original file line number Diff line number Diff line change 315
315
export PROGRESS_TOTAL=$(( OPTIONAL_STEPS + 7 ))
316
316
317
317
init-progress
318
- echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress- total
318
+ echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress/ total
319
319
export PROGRESS_TYPE=" Restore"
320
- echo " $PROGRESS_TYPE " > /tmp/backup-utils-progress- type
320
+ echo " $PROGRESS_TYPE " > /tmp/backup-utils-progress/ type
321
321
export PROGRESS=0 # Used to track progress of restore
322
- echo " $PROGRESS " > /tmp/backup-utils-progress
322
+ echo " $PROGRESS " > /tmp/backup-utils-progress/progress
323
323
324
324
# Log restore start message locally and in /var/log/syslog on remote instance
325
325
START_TIME=$( date +%s)
Original file line number Diff line number Diff line change @@ -652,12 +652,21 @@ restore-secret() {
652
652
653
653
# initialize progress tracking by clearing out the temp files used to track
654
654
init-progress () {
655
- rm -f /tmp/backup-utils-progress*
655
+ if [ -d /tmp/backup-utils-progress ]; then
656
+ rm -rf /tmp/backup-utils-progress/*
657
+ else
658
+ mkdir /tmp/backup-utils-progress
659
+ fi
660
+ touch /tmp/backup-utils-progress/total
661
+ touch /tmp/backup-utils-progress/type
662
+ touch /tmp/backup-utils-progress/progress
663
+ touch /tmp/backup-utils-progress/info
664
+ chmod -R 777 /tmp/backup-utils-progress
656
665
}
657
666
658
667
659
668
# increase total count of progress
660
669
increment-progress-total-count () {
661
670
(( PROGRESS_TOTAL += $1 ))
662
- echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress- total
671
+ echo " $PROGRESS_TOTAL " > /tmp/backup-utils-progress/ total
663
672
}
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
# / track-progress: track progress of backup or restore tasks
3
3
4
- # Current version is working solely with backups
5
4
progress (){
6
5
7
- PROGRESS=$( cat /tmp/backup-utils-progress)
8
- PROGRESS_TOTAL=$( cat /tmp/backup-utils-progress- total)
9
- PROGRESS_TYPE=$( cat /tmp/backup-utils-progress- type)
6
+ PROGRESS=$( cat /tmp/backup-utils-progress/progress )
7
+ PROGRESS_TOTAL=$( cat /tmp/backup-utils-progress/ total)
8
+ PROGRESS_TYPE=$( cat /tmp/backup-utils-progress/ type)
10
9
PROGRESS_PERCENT=$( echo " scale = 2; ($PROGRESS / $PROGRESS_TOTAL ) * 100" | bc)
11
- echo $(( PROGRESS + 1 )) > /tmp/backup-utils-progress
12
- echo " ${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress- info
10
+ echo $(( PROGRESS + 1 )) > /tmp/backup-utils-progress/progress
11
+ echo " ${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress/ info
13
12
}
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ begin_test "ghe-backup subsequent snapshot"
47
47
[ " $first_snapshot " != " $this_snapshot " ]
48
48
49
49
verify_all_backedup_data
50
+
51
+ verify_progress_cleanup_process
50
52
)
51
53
end_test
52
54
Original file line number Diff line number Diff line change @@ -528,6 +528,12 @@ verify_all_backedup_data() {
528
528
verify_common_data
529
529
}
530
530
531
+ # A unified method to make sure post backup, the cleanup process works
532
+ verify_progress_cleanup_process () {
533
+ set -e
534
+ sudo -u nobody rm -rf /tmp/backup-utils-progress/*
535
+ }
536
+
531
537
# A unified method to check everything restored when performing a full restore
532
538
# during testing.
533
539
verify_all_restored_data () {
You can’t perform that action at this time.
0 commit comments