From 7df0a8200eb7e31e4c90c73fc9889e480c5dde25 Mon Sep 17 00:00:00 2001 From: Dave Conroy Date: Wed, 6 Jun 2018 07:19:28 -0700 Subject: [PATCH] 1.7 - Manual Backup Support (type backup-now inside container) --- CHANGELOG.md | 4 ++++ Dockerfile | 23 ++++++++++++----------- README.md | 7 +++++-- install/etc/s6/services/10-db-backup/run | 18 ++++++++++++++---- install/usr/local/bin/backup-now | 4 ++++ 5 files changed, 39 insertions(+), 17 deletions(-) create mode 100755 install/usr/local/bin/backup-now diff --git a/CHANGELOG.md b/CHANGELOG.md index 9310efd..62545c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.7 - 2018-06-06 - + +* Added ability for Manual Backup (enter container and type `backup-now`) + ## 1.6 - 2018-02-26 - * Add Parallel Compression mode (Default TRUE diff --git a/Dockerfile b/Dockerfile index 94d962c..fd7f188 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,22 +28,23 @@ LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)" redis \ xz \ ; \ + \ apk add \ influxdb@testing \ pixz@testing \ ; \ \ - cd /usr/src ; \ - mkdir -p pbzip2 ; \ - curl -ssL https://launchpad.net/pbzip2/1.1/1.1.13/+download/pbzip2-1.1.13.tar.gz | tar xvfz - --strip=1 -C /usr/src/pbzip2 ; \ - cd pbzip2 ; \ - make ; \ - make install ; \ - \ - # Cleanup - rm -rf /usr/src/* ; \ - apk del .db-backup-build-deps ; \ - rm -rf /tmp/* /var/cache/apk/* + cd /usr/src ; \ + mkdir -p pbzip2 ; \ + curl -ssL https://launchpad.net/pbzip2/1.1/1.1.13/+download/pbzip2-1.1.13.tar.gz | tar xvfz - --strip=1 -C /usr/src/pbzip2 ; \ + cd pbzip2 ; \ + make ; \ + make install ; \ + \ + # Cleanup + rm -rf /usr/src/* ; \ + apk del .db-backup-build-deps ; \ + rm -rf /tmp/* /var/cache/apk/* ### S6 Setup ADD install / diff --git a/README.md b/README.md index 14c23c9..e065757 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Currently backs up CouchDB, InfluxDB, MySQL, MongoDB Postgres, Redis, Rethink se * select how often to run a dump * select when to start the first dump, whether time of day or relative to container start time -This Container uses Alpine:Edge as a base. +This Container uses a [customized version of](https://hub.docker.com/r/tiredofit/alpine) alpine:edge as a base. [Changelog](CHANGELOG.md) @@ -69,7 +69,7 @@ The following directories are used for configuration and can be mapped for persi | Directory | Description | |-----------|-------------| -| `/backups` | Backups | +| `/backup` | Backups | ## Environment Variables @@ -99,6 +99,9 @@ Along with the Environment Variables from the [Base image](https://hub.docker.co ## Maintenance + +Manual Backups can be perforemd by entering the container and typing `backup-now` + #### Shell Access For debugging and maintenance purposes you may want access the containers shell. diff --git a/install/etc/s6/services/10-db-backup/run b/install/etc/s6/services/10-db-backup/run index 8c2e654..87014a4 100755 --- a/install/etc/s6/services/10-db-backup/run +++ b/install/etc/s6/services/10-db-backup/run @@ -2,8 +2,11 @@ date >/dev/null +if [ $1 != "NOW" ]; then + sleep 10 +fi + ### Set Debug Mode -sleep 10 if [ "$DEBUG_MODE" = "TRUE" ] || [ "$DEBUG_MODE" = "true" ]; then set -x fi @@ -34,8 +37,12 @@ MD5=${MD5:-TRUE} SPLIT_DB=${SPLIT_DB:-FALSE} TMPDIR=/tmp/backups -### Set Compression Options +if [ $1 = "NOW" ]; then + DB_DUMP_BEGIN=+0 + MANUAL=TRUE +fi +### Set Compression Options if [ "$PARALLEL_COMPRESSION" = "TRUE " ]; then BZIP="pbzip2" GZIP="pigz" @@ -225,7 +232,6 @@ echo '** [db-backup] Initialized at at '$(date) current_time=$(date +"%s") today=$(date +"%Y%m%d") - if [[ $DB_DUMP_BEGIN =~ ^\+(.*)$ ]]; then waittime=$(( ${BASH_REMATCH[1]} * 60 )) else @@ -285,7 +291,11 @@ echo '** [db-backup] Initialized at at '$(date) fi ### Go back to Sleep until next Backup time - sleep $(($DB_DUMP_FREQ*60)) + if [ "$MANUAL" = "TRUE" ]; then + exit 1; + else + sleep $(($DB_DUMP_FREQ*60)) + fi done fi \ No newline at end of file diff --git a/install/usr/local/bin/backup-now b/install/usr/local/bin/backup-now new file mode 100755 index 0000000..77abc19 --- /dev/null +++ b/install/usr/local/bin/backup-now @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash + +echo '** Performing Manual Backup' +/etc/s6/services/10-db-backup/run NOW