Skip to content

Commit d0bc8ad

Browse files
authored
Merge pull request #573 from github/enterprise-3.10-backport-558-fix-permissions-prog
Backport 558 for 3.10: add 777 permissions to backup progress tmp files
2 parents a7f7945 + 248c1ae commit d0bc8ad

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

bin/ghe-backup

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ echo "$GHE_REMOTE_VERSION" > version
163163
# Setup progress tracking
164164
init-progress
165165
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
167167
export PROGRESS_TYPE="Backup"
168-
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
168+
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type
169169
export PROGRESS=0 # Used to track progress of backup
170-
echo "$PROGRESS" > /tmp/backup-utils-progress
170+
echo "$PROGRESS" > /tmp/backup-utils-progress/progress
171171

172172
OPTIONAL_STEPS=0
173173
# Backup actions+mssql
@@ -191,7 +191,7 @@ if [ "$GHE_BACKUP_PAGES" != "no" ]; then
191191
fi
192192

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

196196
# check that incremental settings are valid if set
197197
is_inc=$(is_incremental_backup_feature_on)

bin/ghe-backup-progress

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,26 @@ while true; do
3131
done
3232

3333
check_for_progress_file() {
34-
if [ ! -f /tmp/backup-utils-progress-info ]; then
34+
if [ ! -f /tmp/backup-utils-progress/info ]; then
3535
echo "No progress file found. Has a backup or restore been started?"
3636
exit 1
3737
fi
3838
}
3939

4040
if [ -n "$ONCE" ]; then
4141
check_for_progress_file
42-
cat /tmp/backup-utils-progress-info
42+
cat /tmp/backup-utils-progress/info
4343
else
4444
check_for_progress_file
4545
clear
46-
cat /tmp/backup-utils-progress-info
46+
cat /tmp/backup-utils-progress/info
4747
while true; do
4848
if read -r -t 1 -n 1; then
4949
clear
5050
exit ;
5151
else
5252
clear
53-
cat /tmp/backup-utils-progress-info
53+
cat /tmp/backup-utils-progress/info
5454
fi
5555
done
5656
fi

bin/ghe-restore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@ fi
315315
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7))
316316

317317
init-progress
318-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
318+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
319319
export PROGRESS_TYPE="Restore"
320-
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
320+
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type
321321
export PROGRESS=0 # Used to track progress of restore
322-
echo "$PROGRESS" > /tmp/backup-utils-progress
322+
echo "$PROGRESS" > /tmp/backup-utils-progress/progress
323323

324324
# Log restore start message locally and in /var/log/syslog on remote instance
325325
START_TIME=$(date +%s)

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,21 @@ restore-secret() {
652652

653653
#initialize progress tracking by clearing out the temp files used to track
654654
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
656665
}
657666

658667

659668
#increase total count of progress
660669
increment-progress-total-count() {
661670
((PROGRESS_TOTAL += $1))
662-
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
671+
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
663672
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env bash
22
#/ track-progress: track progress of backup or restore tasks
33

4-
# Current version is working solely with backups
54
progress(){
65

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)
109
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
1312
}

test/test-ghe-backup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ begin_test "ghe-backup subsequent snapshot"
4747
[ "$first_snapshot" != "$this_snapshot" ]
4848

4949
verify_all_backedup_data
50+
51+
verify_progress_cleanup_process
5052
)
5153
end_test
5254

test/testlib.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ verify_all_backedup_data() {
494494
verify_common_data
495495
}
496496

497+
# A unified method to make sure post backup, the cleanup process works
498+
verify_progress_cleanup_process() {
499+
set -e
500+
sudo -u nobody rm -rf /tmp/backup-utils-progress/*
501+
}
502+
497503
# A unified method to check everything restored when performing a full restore
498504
# during testing.
499505
verify_all_restored_data() {

0 commit comments

Comments
 (0)