Skip to content

Commit 06cfba4

Browse files
committed
Modify DB_DUMP_BEGIN to support a full date as cron
1 parent 250cae9 commit 06cfba4

File tree

1 file changed

+10
-7
lines changed
  • install/etc/services.available/10-db-backup

1 file changed

+10
-7
lines changed

install/etc/services.available/10-db-backup/run

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ else
2727
print_debug "DB_DUMP_BEGIN is an integer."
2828
waittime=$(( ${BASH_REMATCH[1]} * 60 ))
2929
target_time=$(($current_time + $waittime))
30-
elif [[ $DB_DUMP_BEGIN =~ ^([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]]; then
31-
print_debug "DB_DUMP_BEGIN is a time."
32-
# Extract hours, minutes, and seconds from DB_DUMP_BEGIN
33-
db_hour=${BASH_REMATCH[1]}
34-
db_minute=${BASH_REMATCH[2]}
35-
db_second=${BASH_REMATCH[3]}
30+
elif [[ $DB_DUMP_BEGIN =~ ^([0-9]{4})-([0-9]{2})-([0-9]{2})[[:space:]]([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]];
31+
then
32+
# Extract year, month, day, hours, minutes, and seconds from DB_DUMP_BEGIN
33+
db_year=${BASH_REMATCH[1]}
34+
db_month=${BASH_REMATCH[2]}
35+
db_day=${BASH_REMATCH[3]}
36+
db_hour=${BASH_REMATCH[4]}
37+
db_minute=${BASH_REMATCH[5]}
38+
db_second=${BASH_REMATCH[6]}
3639

3740
# Calculate DB_DUMP_BEGIN time in seconds
38-
db_time=$(date -d "${db_hour}:${db_minute}:${db_second}" +%s)
41+
db_time=$(date -d "${db_year}-${db_month}-${db_day} ${db_hour}:${db_minute}:${db_second}" +%s)
3942
print_debug "DB time = $db_time"
4043

4144
# Calculate the difference in seconds

0 commit comments

Comments
 (0)