mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 21:33:28 +01:00
Code refactoring
This commit is contained in:
@@ -33,20 +33,12 @@ else
|
||||
waittime=$(($target_time - $current_time))
|
||||
elif [[ $DB_DUMP_BEGIN =~ ^([0-9]{4})-([0-9]{2})-([0-9]{2})[[:space:]]([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]];
|
||||
then
|
||||
# Extract year, month, day, hours, minutes, and seconds from DB_DUMP_BEGIN
|
||||
db_year=${BASH_REMATCH[1]}
|
||||
db_month=${BASH_REMATCH[2]}
|
||||
db_day=${BASH_REMATCH[3]}
|
||||
db_hour=${BASH_REMATCH[4]}
|
||||
db_minute=${BASH_REMATCH[5]}
|
||||
db_second=${BASH_REMATCH[6]}
|
||||
|
||||
# Calculate DB_DUMP_BEGIN time in seconds
|
||||
db_time=$(date -d "${db_year}-${db_month}-${db_day} ${db_hour}:${db_minute}:${db_second}" +%s)
|
||||
print_debug "DB time = $db_time"
|
||||
dump_time=$(date -d "${DB_DUMP_BEGIN}" +%s)
|
||||
print_debug "Dump time = $dump_time"
|
||||
|
||||
# Calculate the difference in seconds
|
||||
waittime=$((db_time - current_time))
|
||||
waittime=$((dump_time - current_time))
|
||||
print_debug "Difference in seconds: $waittime"
|
||||
|
||||
if (( $waittime < 0 )); then
|
||||
@@ -58,7 +50,7 @@ else
|
||||
target_time=$(($current_time + $waittime))
|
||||
print_debug "Target time = $target_time"
|
||||
else
|
||||
print_info "DB_DUMP_BEGIN is not starting with + or is not an integer or is not in the correct format (hh:mm:ss)."
|
||||
print_info "DB_DUMP_BEGIN is not starting with + or is not an integer or is not in the correct format (YYYY-mm-dd hh:mm:ss)."
|
||||
fi
|
||||
|
||||
print_debug "******** End DB_DUMP_BEGIN ********"
|
||||
|
||||
Reference in New Issue
Block a user