From e502297f744865c603c08a96e1ee8b5ca46cfd16 Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Fri, 10 Aug 2018 19:32:01 +0100 Subject: [PATCH] Better handling of backup and restore progress files --- src/freedombone-installer | 19 +++++++++++-------- src/freedombone-utils-backup | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/freedombone-installer b/src/freedombone-installer index 433831456..f82d9e8a9 100755 --- a/src/freedombone-installer +++ b/src/freedombone-installer @@ -800,6 +800,10 @@ function initiate_automatic_backup { } function update_backup_progress_bar { + if [ ! -f "$backup_progress_file" ]; then + return + fi + backup_process_exists= backup_process=$(pgrep 'webadmin_backup.sh' | grep -v 'grep') if [ "$backup_process" ]; then @@ -815,10 +819,6 @@ function update_backup_progress_bar { return fi - # shellcheck disable=SC2086 - if [ ! -f "$backup_progress_file" ]; then - echo -n '1' > "$backup_progress_file" - fi max_counter=203 progress_page="$webadmin_install_dir/backup_progress.html" progress_counter=$(cat $backup_progress_file) @@ -830,6 +830,9 @@ function update_backup_progress_bar { } function update_restore_progress_bar { + if [ ! -f "$restore_progress_file" ]; then + return + fi restore_process_exists= restore_process=$(pgrep 'webadmin_restore.sh' | grep -v 'grep') if [ "$restore_process" ]; then @@ -845,10 +848,6 @@ function update_restore_progress_bar { return fi - # shellcheck disable=SC2086 - if [ ! -f "$restore_progress_file" ]; then - echo -n '1' > "$restore_progress_file" - fi max_counter=203 progress_page="$webadmin_install_dir/restore_progress.html" progress_counter=$(cat $restore_progress_file) @@ -915,6 +914,8 @@ function backup_and_restore { echo "cp $webadmin_install_dir/index.html $webadmin_install_dir/restore_progress.html"; echo "chown www-data:www-data $webadmin_install_dir/restore_progress.html"; echo ''; + echo "rm $restore_progress_file"; + echo ''; echo "exit 0"; } > $restore_script chmod +x $restore_script @@ -963,6 +964,8 @@ function backup_and_restore { echo "cp $webadmin_install_dir/index.html $webadmin_install_dir/backup_progress.html"; echo "chown www-data:www-data $webadmin_install_dir/backup_progress.html"; echo ''; + echo "rm $backup_progress_file"; + echo ''; echo "exit 0"; } > $backup_script chmod +x $backup_script diff --git a/src/freedombone-utils-backup b/src/freedombone-utils-backup index ad1637435..44c5cbc52 100755 --- a/src/freedombone-utils-backup +++ b/src/freedombone-utils-backup @@ -39,8 +39,9 @@ BACKUP_GPG_OPTIONS="--pinentry-mode loopback" # This is used to detect drives later connected DRIVES_BASELINE_FILE=/root/.drives_baseline +# Files which contain the percentage progress backup_progress_file=/root/.backup_progress.txt - +restore_progress_file=/root/.backup_progress.txt function create_backups_temp_directory { if [ ! -d $BACKUP_TEMP_DIRECTORY ]; then -- GitLab