Skip to content

Commit

Permalink
Merge pull request databacker#86 from deitch/fix-cron-parsing
Browse files Browse the repository at this point in the history
Fix calls to wait_for_cron to pass correct parameters
  • Loading branch information
deitch authored Feb 5, 2019
2 parents 2868cba + 3fddbe7 commit c077778
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ else
# wait for the next time to start a backup
# for debugging
echo Starting at $(date)
current_time=$(date +"%s")
current_time_full=$(date +"%Y.%m.%d-%H:%M:%S")
current_time=$(date --date="$current_time_full" +"%s")
freq_time=$(($DB_DUMP_FREQ*60))
# get the begin time on our date
# REMEMBER: we are using the basic date package in alpine
# could be a delay in minutes or an absolute time of day
if [ -n "$DB_DUMP_CRON" ]; then
# calculate how long until the next cron instance is met
waittime=$(wait_for_cron "$DB_DUMP_CRON")
waittime=$(wait_for_cron "$DB_DUMP_CRON" "$current_time_full")
elif [[ $DB_DUMP_BEGIN =~ ^\+(.*)$ ]]; then
waittime=$(( ${BASH_REMATCH[1]} * 60 ))
target_time=$(($current_time + $waittime))
Expand Down Expand Up @@ -194,10 +195,12 @@ else
/bin/rm ${TMPDIR}/${SOURCE}

# wait, unless RUN_ONCE is set
current_time_full=$(date +"%Y.%m.%d-%H:%M:%S")
current_time=$(date --date="$current_time_full" +"%s")
if [ -n "${RUN_ONCE}" ]; then
exit 0
elif [ -n "${DB_DUMP_CRON}" ]; then
waittime=$(wait_for_cron "${DB_DUMP_CRON}")
waittime=$(wait_for_cron "${DB_DUMP_CRON}" "$current_time_full")
else
current_time=$(date +"%s")
# Calculate how long the previous backup took
Expand Down

0 comments on commit c077778

Please sign in to comment.