add post backup cleanup and move progress to folder (#558)
This commit is contained in:
Родитель
a7f79453d8
Коммит
248c1ae162
|
@ -163,11 +163,11 @@ echo "$GHE_REMOTE_VERSION" > version
|
|||
# Setup progress tracking
|
||||
init-progress
|
||||
export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
|
||||
export PROGRESS_TYPE="Backup"
|
||||
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
|
||||
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type
|
||||
export PROGRESS=0 # Used to track progress of backup
|
||||
echo "$PROGRESS" > /tmp/backup-utils-progress
|
||||
echo "$PROGRESS" > /tmp/backup-utils-progress/progress
|
||||
|
||||
OPTIONAL_STEPS=0
|
||||
# Backup actions+mssql
|
||||
|
@ -191,7 +191,7 @@ if [ "$GHE_BACKUP_PAGES" != "no" ]; then
|
|||
fi
|
||||
|
||||
PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
|
||||
|
||||
# check that incremental settings are valid if set
|
||||
is_inc=$(is_incremental_backup_feature_on)
|
||||
|
|
|
@ -31,7 +31,7 @@ while true; do
|
|||
done
|
||||
|
||||
check_for_progress_file() {
|
||||
if [ ! -f /tmp/backup-utils-progress-info ]; then
|
||||
if [ ! -f /tmp/backup-utils-progress/info ]; then
|
||||
echo "No progress file found. Has a backup or restore been started?"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -39,18 +39,18 @@ check_for_progress_file() {
|
|||
|
||||
if [ -n "$ONCE" ]; then
|
||||
check_for_progress_file
|
||||
cat /tmp/backup-utils-progress-info
|
||||
cat /tmp/backup-utils-progress/info
|
||||
else
|
||||
check_for_progress_file
|
||||
clear
|
||||
cat /tmp/backup-utils-progress-info
|
||||
cat /tmp/backup-utils-progress/info
|
||||
while true; do
|
||||
if read -r -t 1 -n 1; then
|
||||
clear
|
||||
exit ;
|
||||
else
|
||||
clear
|
||||
cat /tmp/backup-utils-progress-info
|
||||
cat /tmp/backup-utils-progress/info
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -315,11 +315,11 @@ fi
|
|||
export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7))
|
||||
|
||||
init-progress
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
|
||||
export PROGRESS_TYPE="Restore"
|
||||
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type
|
||||
echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type
|
||||
export PROGRESS=0 # Used to track progress of restore
|
||||
echo "$PROGRESS" > /tmp/backup-utils-progress
|
||||
echo "$PROGRESS" > /tmp/backup-utils-progress/progress
|
||||
|
||||
# Log restore start message locally and in /var/log/syslog on remote instance
|
||||
START_TIME=$(date +%s)
|
||||
|
|
|
@ -652,12 +652,21 @@ restore-secret() {
|
|||
|
||||
#initialize progress tracking by clearing out the temp files used to track
|
||||
init-progress() {
|
||||
rm -f /tmp/backup-utils-progress*
|
||||
if [ -d /tmp/backup-utils-progress ]; then
|
||||
rm -rf /tmp/backup-utils-progress/*
|
||||
else
|
||||
mkdir /tmp/backup-utils-progress
|
||||
fi
|
||||
touch /tmp/backup-utils-progress/total
|
||||
touch /tmp/backup-utils-progress/type
|
||||
touch /tmp/backup-utils-progress/progress
|
||||
touch /tmp/backup-utils-progress/info
|
||||
chmod -R 777 /tmp/backup-utils-progress
|
||||
}
|
||||
|
||||
|
||||
#increase total count of progress
|
||||
increment-progress-total-count() {
|
||||
((PROGRESS_TOTAL += $1))
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total
|
||||
echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
#/ track-progress: track progress of backup or restore tasks
|
||||
|
||||
# Current version is working solely with backups
|
||||
progress(){
|
||||
|
||||
PROGRESS=$(cat /tmp/backup-utils-progress)
|
||||
PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress-total)
|
||||
PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type)
|
||||
PROGRESS=$(cat /tmp/backup-utils-progress/progress)
|
||||
PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress/total)
|
||||
PROGRESS_TYPE=$(cat /tmp/backup-utils-progress/type)
|
||||
PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc)
|
||||
echo $((PROGRESS + 1)) > /tmp/backup-utils-progress
|
||||
echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info
|
||||
echo $((PROGRESS + 1)) > /tmp/backup-utils-progress/progress
|
||||
echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress/info
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ begin_test "ghe-backup subsequent snapshot"
|
|||
[ "$first_snapshot" != "$this_snapshot" ]
|
||||
|
||||
verify_all_backedup_data
|
||||
|
||||
verify_progress_cleanup_process
|
||||
)
|
||||
end_test
|
||||
|
||||
|
|
|
@ -494,6 +494,12 @@ verify_all_backedup_data() {
|
|||
verify_common_data
|
||||
}
|
||||
|
||||
# A unified method to make sure post backup, the cleanup process works
|
||||
verify_progress_cleanup_process() {
|
||||
set -e
|
||||
sudo -u nobody rm -rf /tmp/backup-utils-progress/*
|
||||
}
|
||||
|
||||
# A unified method to check everything restored when performing a full restore
|
||||
# during testing.
|
||||
verify_all_restored_data() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче