From b38ad7a5cc9a356f54ea009b50f1b1b7a8a408d5 Mon Sep 17 00:00:00 2001 From: "Yao (Alwyn) Pan" Date: Fri, 18 Sep 2020 14:32:08 +1000 Subject: [PATCH 1/2] #44 Remove 'invalid date' error message when performing backup-now --- .../etc/services.available/10-db-backup/run | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/install/etc/services.available/10-db-backup/run b/install/etc/services.available/10-db-backup/run index bb7deb2..f8a5242 100755 --- a/install/etc/services.available/10-db-backup/run +++ b/install/etc/services.available/10-db-backup/run @@ -394,21 +394,23 @@ move_backup() { print_debug "Backup routines Initialized on $(date)" ### Wait for Next time to start backup - current_time=$(date +"%s") - today=$(date +"%Y%m%d") + if [ "$1" != "NOW" ]; then + current_time=$(date +"%s") + today=$(date +"%Y%m%d") - if [[ $DB_DUMP_BEGIN =~ ^\+(.*)$ ]]; then - waittime=$(( ${BASH_REMATCH[1]} * 60 )) - else - target_time=$(date --date="${today}${DB_DUMP_BEGIN}" +"%s") - if [[ "$target_time" < "$current_time" ]]; then - target_time=$(($target_time + 24*60*60)) + if [[ $DB_DUMP_BEGIN =~ ^\+(.*)$ ]]; then + waittime=$(( ${BASH_REMATCH[1]} * 60 )) + else + target_time=$(date --date="${today}${DB_DUMP_BEGIN}" +"%s") + if [[ "$target_time" < "$current_time" ]]; then + target_time=$(($target_time + 24*60*60)) + fi + waittime=$(($target_time - $current_time)) fi - waittime=$(($target_time - $current_time)) - fi - print_notice "Next Backup at $(date -d @${target_time} +"%Y-%m-%d %T %Z")" - sleep $waittime + print_notice "Next Backup at $(date -d @${target_time} +"%Y-%m-%d %T %Z")" + sleep $waittime + fi ### Commence Backup From 1bc357866fa72d0fccf962ac5fadc8a3f454df1c Mon Sep 17 00:00:00 2001 From: "Yao (Alwyn) Pan" Date: Fri, 18 Sep 2020 14:34:06 +1000 Subject: [PATCH 2/2] #42 Update README --- README.md | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1cc5e21..fe34925 100644 --- a/README.md +++ b/README.md @@ -32,28 +32,29 @@ Currently backs up CouchDB, InfluxDB, MySQL, MongoDB, Postgres, Redis servers. ## Table of Contents -- [Introduction](#introduction) -- [Authors](#authors) -- [Table of Contents](#table-of-contents) -- [Prerequisites](#prerequisites) -- [Installation](#installation) - - [Quick Start](#quick-start) -- [Configuration](#configuration) - - [Data-Volumes](#data-volumes) - - [Environment Variables](#environment-variables) -- [Maintenance](#maintenance) - - [Shell Access](#shell-access) - - [Custom Scripts](#custom-scripts) -- [Example Post Script](#example-post-script) -- [$1=EXIT_CODE (After running backup routine)](#1exit_code-after-running-backup-routine) -- [$2=DB_TYPE (Type of Backup)](#2db_type-type-of-backup) -- [$3=DB_HOST (Backup Host)](#3db_host-backup-host) -- [#4=DB_NAME (Name of Database backed up](#4db_name-name-of-database-backed-up) -- [$5=DATE (Date of Backup)](#5date-date-of-backup) -- [$6=TIME (Time of Backup)](#6time-time-of-backup) -- [$7=BACKUP_FILENAME (Filename of Backup)](#7backup_filename-filename-of-backup) -- [$8=FILESIZE (Filesize of backup)](#8filesize-filesize-of-backup) -- [$9=MD5_RESULT (MD5Sum if enabled)](#9md5_result-md5sum-if-enabled) +- [hub.docker.com/r/tiredofit/db-backup](#hubdockercomrtiredofitdb-backup) + - [Introduction](#introduction) + - [Authors](#authors) + - [Table of Contents](#table-of-contents) + - [Prerequisites](#prerequisites) + - [Installation](#installation) + - [Quick Start](#quick-start) + - [Configuration](#configuration) + - [Data-Volumes](#data-volumes) + - [Environment Variables](#environment-variables) + - [Maintenance](#maintenance) + - [Shell Access](#shell-access) + - [Custom Scripts](#custom-scripts) + - [Example Post Script](#example-post-script) + - [$1=EXIT_CODE (After running backup routine)](#1exit_code-after-running-backup-routine) + - [$2=DB_TYPE (Type of Backup)](#2db_type-type-of-backup) + - [$3=DB_HOST (Backup Host)](#3db_host-backup-host) + - [#4=DB_NAME (Name of Database backed up](#4db_name-name-of-database-backed-up) + - [$5=DATE (Date of Backup)](#5date-date-of-backup) + - [$6=TIME (Time of Backup)](#6time-time-of-backup) + - [$7=BACKUP_FILENAME (Filename of Backup)](#7backup_filename-filename-of-backup) + - [$8=FILESIZE (Filesize of backup)](#8filesize-filesize-of-backup) + - [$9=MD5_RESULT (MD5Sum if enabled)](#9md5_result-md5sum-if-enabled) ## Prerequisites @@ -90,8 +91,6 @@ The following directories are used for configuration and can be mapped for persi ### Environment Variables -*If you are trying to backup a database that doesn't have a user or a password (you should!) make sure you set `CONTAINER_ENABLE_DOCKER_SECRETS=FALSE`* - Along with the Environment Variables from the [Base image](https://hub.docker.com/r/tiredofit/alpine), below is the complete list of available options that can be used to customize your installation. | Parameter | Description |