Skip to content

Commit e42f8e9

Browse files
committed
Code refactoring
1 parent 6a28ac2 commit e42f8e9

File tree

1 file changed

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

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,12 @@ else
3333
waittime=$(($target_time - $current_time))
3434
elif [[ $DB_DUMP_BEGIN =~ ^([0-9]{4})-([0-9]{2})-([0-9]{2})[[:space:]]([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]];
3535
then
36-
# Extract year, month, day, hours, minutes, and seconds from DB_DUMP_BEGIN
37-
db_year=${BASH_REMATCH[1]}
38-
db_month=${BASH_REMATCH[2]}
39-
db_day=${BASH_REMATCH[3]}
40-
db_hour=${BASH_REMATCH[4]}
41-
db_minute=${BASH_REMATCH[5]}
42-
db_second=${BASH_REMATCH[6]}
43-
4436
# Calculate DB_DUMP_BEGIN time in seconds
45-
db_time=$(date -d "${db_year}-${db_month}-${db_day} ${db_hour}:${db_minute}:${db_second}" +%s)
46-
print_debug "DB time = $db_time"
37+
dump_time=$(date -d "${DB_DUMP_BEGIN}" +%s)
38+
print_debug "Dump time = $dump_time"
4739

4840
# Calculate the difference in seconds
49-
waittime=$((db_time - current_time))
41+
waittime=$((dump_time - current_time))
5042
print_debug "Difference in seconds: $waittime"
5143

5244
if (( $waittime < 0 )); then
@@ -58,7 +50,7 @@ else
5850
target_time=$(($current_time + $waittime))
5951
print_debug "Target time = $target_time"
6052
else
61-
print_info "DB_DUMP_BEGIN is not starting with + or is not an integer or is not in the correct format (hh:mm:ss)."
53+
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)."
6254
fi
6355

6456
print_debug "******** End DB_DUMP_BEGIN ********"

0 commit comments

Comments
 (0)