mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 13:23:12 +01:00
Code formatting and cleanup
This commit is contained in:
@@ -31,7 +31,7 @@ else
|
||||
elif [[ "${backup_job_backup_begin}" =~ ([0-9]{4})-([0-9]{2})-([0-9]{2})[[:space:]]([0-9]{2}):([0-9]{2}):([0-9]{2}) ]]; then
|
||||
print_debug "BACKUP_BEGIN is a full date timestamp"
|
||||
timer datetime
|
||||
elif echo ${backup_job_backup_begin//\*/#} | grep -qP "^(((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|#) ?){5}$" ; then
|
||||
elif echo "${backup_job_backup_begin//\*/#}" | grep -qP "^(((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|#) ?){5}$" ; then
|
||||
print_debug "BACKUP_BEGIN is a cron expression"
|
||||
time_last_run=$(date +"%s")
|
||||
timer cron "${backup_job_backup_begin}" "${time_current}" "${time_last_run}"
|
||||
@@ -52,8 +52,8 @@ EOF
|
||||
fi
|
||||
|
||||
print_debug "Wait Time: ${time_wait} Future execution time: ${time_future} Current Time: ${time_current}"
|
||||
print_info "Next Backup at $(date -d @${time_future} +'%Y-%m-%d %T %Z')"
|
||||
silent sleep ${time_wait}
|
||||
print_info "Next Backup at $(date -d @"${time_future}" +'%Y-%m-%d %T %Z')"
|
||||
silent sleep "${time_wait}"
|
||||
fi
|
||||
|
||||
while true; do
|
||||
@@ -75,11 +75,11 @@ while true; do
|
||||
print_debug "Backup {{BACKUP_NUMBER}} routines started time: $(date +'%Y-%m-%d %T %Z')"
|
||||
bootstrap_filesystem
|
||||
check_availability
|
||||
backup_${dbtype,,}
|
||||
backup_"${dbtype,,}"
|
||||
timer job stop
|
||||
if [ -z "${exitcode_backup}" ] ; then exitcode_backup="0" ; fi
|
||||
print_info "Backup {{BACKUP_NUMBER}} routines finish time: $(date -d @${backup_job_finish_time} +'%Y-%m-%d %T %Z') with exit code ${exitcode_backup}"
|
||||
print_notice "Backup {{BACKUP_NUMBER}} routines time taken: $(echo ${backup_job_total_time} | awk '{printf "Hours: %d Minutes: %02d Seconds: %02d", $1/3600, ($1/60)%60, $1%60}')"
|
||||
print_info "Backup {{BACKUP_NUMBER}} routines finish time: $(date -d @"${backup_job_finish_time}" +'%Y-%m-%d %T %Z') with exit code ${exitcode_backup}"
|
||||
print_notice "Backup {{BACKUP_NUMBER}} routines time taken: $(echo "${backup_job_total_time}" | awk '{printf "Hours: %d Minutes: %02d Seconds: %02d", $1/3600, ($1/60)%60, $1%60}')"
|
||||
sed -i "/^{{BACKUP_NUMBER}}/d" /tmp/.container/db-backup-backups
|
||||
fi
|
||||
|
||||
@@ -87,7 +87,7 @@ while true; do
|
||||
|
||||
if var_false "${persist}" ; then
|
||||
print_debug "Exiting due to manual mode"
|
||||
exit ${exitcode_backup};
|
||||
exit "${exitcode_backup}";
|
||||
else
|
||||
if var_true "${stop_scheduler_backup}" ; then
|
||||
print_error "Stopping backup_scheduler {{BACKUP_NUMBER}} due to detected errors. Fix and restart container."
|
||||
@@ -99,8 +99,8 @@ while true; do
|
||||
else
|
||||
time_last_run=$(date +"%s")
|
||||
timer cron "${backup_job_backup_begin}" "${time_current}" "${time_last_run}"
|
||||
print_notice "Sleeping for another ${time_wait} seconds. Waking up at $(date -d@${time_future} +'%Y-%m-%d %T %Z') "
|
||||
silent sleep ${time_wait}
|
||||
print_notice "Sleeping for another ${time_wait} seconds. Waking up at $(date -d@"${time_future}" +'%Y-%m-%d %T %Z') "
|
||||
silent sleep "${time_wait}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user