mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-23 22:18:10 +01:00
Modify DB_DUMP_BEGIN to support a full date as cron
This commit is contained in:
@@ -27,15 +27,18 @@ else
|
||||
print_debug "DB_DUMP_BEGIN is an integer."
|
||||
waittime=$(( ${BASH_REMATCH[1]} * 60 ))
|
||||
target_time=$(($current_time + $waittime))
|
||||
elif [[ $DB_DUMP_BEGIN =~ ^([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]]; then
|
||||
print_debug "DB_DUMP_BEGIN is a time."
|
||||
# Extract hours, minutes, and seconds from DB_DUMP_BEGIN
|
||||
db_hour=${BASH_REMATCH[1]}
|
||||
db_minute=${BASH_REMATCH[2]}
|
||||
db_second=${BASH_REMATCH[3]}
|
||||
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_hour}:${db_minute}:${db_second}" +%s)
|
||||
db_time=$(date -d "${db_year}-${db_month}-${db_day} ${db_hour}:${db_minute}:${db_second}" +%s)
|
||||
print_debug "DB time = $db_time"
|
||||
|
||||
# Calculate the difference in seconds
|
||||
|
||||
Reference in New Issue
Block a user