From b38ad7a5cc9a356f54ea009b50f1b1b7a8a408d5 Mon Sep 17 00:00:00 2001 From: "Yao (Alwyn) Pan" Date: Fri, 18 Sep 2020 14:32:08 +1000 Subject: [PATCH] #44 Remove 'invalid date' error message when performing backup-now --- .../etc/services.available/10-db-backup/run | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/install/etc/services.available/10-db-backup/run b/install/etc/services.available/10-db-backup/run index bb7deb2..f8a5242 100755 --- a/install/etc/services.available/10-db-backup/run +++ b/install/etc/services.available/10-db-backup/run @@ -394,21 +394,23 @@ move_backup() { print_debug "Backup routines Initialized on $(date)" ### Wait for Next time to start backup - current_time=$(date +"%s") - today=$(date +"%Y%m%d") + if [ "$1" != "NOW" ]; then + current_time=$(date +"%s") + today=$(date +"%Y%m%d") - if [[ $DB_DUMP_BEGIN =~ ^\+(.*)$ ]]; then - waittime=$(( ${BASH_REMATCH[1]} * 60 )) - else - target_time=$(date --date="${today}${DB_DUMP_BEGIN}" +"%s") - if [[ "$target_time" < "$current_time" ]]; then - target_time=$(($target_time + 24*60*60)) + if [[ $DB_DUMP_BEGIN =~ ^\+(.*)$ ]]; then + waittime=$(( ${BASH_REMATCH[1]} * 60 )) + else + target_time=$(date --date="${today}${DB_DUMP_BEGIN}" +"%s") + if [[ "$target_time" < "$current_time" ]]; then + target_time=$(($target_time + 24*60*60)) + fi + waittime=$(($target_time - $current_time)) fi - waittime=$(($target_time - $current_time)) - fi - print_notice "Next Backup at $(date -d @${target_time} +"%Y-%m-%d %T %Z")" - sleep $waittime + print_notice "Next Backup at $(date -d @${target_time} +"%Y-%m-%d %T %Z")" + sleep $waittime + fi ### Commence Backup