Compare commits

...

10 Commits
1.7 ... 1.13

Author SHA1 Message Date
Dave Conroy
9051ba559a Postgres backup fixes 2019-03-09 07:29:51 -08:00
Dave Conroy
bf672c0fda Fix for XZ compression failing 2019-03-01 14:31:10 -08:00
Dave Conroy
9993ad2970 Merge pull request #9 from steve-todorov/issue-2
Issue 2: Fixing typo which was causing the script to fail.
2019-03-01 14:30:20 -08:00
Steve Todorov
dc17d60b7b Issue 2: Fixing typo which was causing the script to fail. 2019-03-02 00:16:43 +02:00
Dave Conroy
49356629fe Update Changelog 2018-11-18 15:18:46 -08:00
Dave Conroy
b938c8a761 Merge pull request #6 from skylord123/skylord123-patch-1
Fix influx args as well as some errors in the log
2018-11-18 15:16:03 -08:00
Skylar Sadlier
5807ba07e3 Update run
influx command actually doesn't accept a port argument, so instead pass it in as part of the host (to keep a uniform config with the other DB types)
2018-11-18 16:09:57 -07:00
Skylar Sadlier
96f3120e35 Update run
Fix "unary operator expected" that appears in the first couple lines of the log
2018-11-18 16:08:07 -07:00
Dave Conroy
af5c6198ce InfluxDB fixes 2018-11-18 10:18:38 -08:00
Dave Conroy
5d1ae25828 Swap out openssl for libressl 2018-11-03 07:48:19 -07:00
5 changed files with 67 additions and 32 deletions

View File

@@ -1,3 +1,28 @@
## 1.13 - 2019-03-09 - <dave at tiredofit dot ca>
* Fixed Postgres backup without SPLIT_DB enabled (credit MelwinKfr@github)
* Added DB_PORT reference to properly backup Postgres with non default ports (thanks Maxximus007@github)
## 1.12 - 2019-03-01 - <stevetodorov at github>
* Fix for XZ Compression failing
## 1.11 - 2018-11-19 - <skylord123 at github>
* Fix for Urnary Operator Error
## 1.10 - 2018-11-19 - <dave at tiredofit dot ca>
* Fix for InfluxDB for backing up and supporting DB_PORT variable - Thanks skylord123@github
## 1.9 - 2018-11-03 - <dave at tiredofit dot ca>
* Switch from OpenSSL to LibreSSL
## 1.8 - 2018-07-18 - <dave at tiredofit dot ca>
* Fix warnings on startup related to 1.7 Changes
## 1.7 - 2018-06-06 - <dave at tiredofit dot ca>
* Added ability for Manual Backup (enter container and type `backup-now`)

View File

@@ -6,45 +6,44 @@ LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)"
ENABLE_SMTP=FALSE
### Dependencies
RUN set -ex ; \
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories ; \
apk update ; \
apk upgrade ; \
RUN set -ex && \
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add --virtual .db-backup-build-deps \
build-base \
bzip2-dev \
git \
xz-dev \
; \
&& \
\
apk add --virtual .db-backup-run-deps \
bzip2 \
mongodb-tools \
mariadb-client \
openssl \
libressl \
pigz \
postgresql \
postgresql-client \
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 /

View File

@@ -1,5 +1,12 @@
# tiredofit/db-backup
[![Build Status](https://img.shields.io/docker/build/tiredofit/db-backup.svg)](https://hub.docker.com/r/tiredofit/db-backup)
[![Docker Pulls](https://img.shields.io/docker/pulls/tiredofit/db-backup.svg)](https://hub.docker.com/r/tiredofit/db-backup)
[![Docker Stars](https://img.shields.io/docker/stars/tiredofit/db-backup.svg)](https://hub.docker.com/r/tiredofit/db-backup)
[![Docker Layers](https://images.microbadger.com/badges/image/tiredofit/db-backup.svg)](https://microbadger.com/images/tiredofit/db-backup)
# Introduction
This will build a container for backing up multiple type of DB Servers
@@ -16,8 +23,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 a [customized version of](https://hub.docker.com/r/tiredofit/alpine) alpine:edge as a base.
This Container uses Alpine:Edge as a base.
[Changelog](CHANGELOG.md)
@@ -45,7 +51,8 @@ You must have a working DB server or container available for this to work proper
# Installation
Automated builds of the image are available on [Docker Hub](https://hub.docker.com/tiredofit/db-backup) and is the recommended method of installation.
Automated builds of the image are available on [Docker Hub](https://hub.docker.com/r/tiredofit/db-backup) and is the recommended
method of installation.
```bash
@@ -80,7 +87,7 @@ Along with the Environment Variables from the [Base image](https://hub.docker.co
| Parameter | Description |
|-----------|-------------|
| `DB_TYPE` | Type of DB Server to backup `couch` `influx` `mysql` `pgsql` `mongo` `redis` `rethink`
| `DB_HOST` | Server Hostname e.g. `mariadb`
| `DB_SERVER` | Server Hostname e.g. `mariadb`
| `DB_NAME` | Schema Name e.g. `database`
| `DB_USER` | username for the database - use `root` to backup all MySQL of them.
| `DB_PASS` | (optional if DB doesn't require it) password for the database
@@ -89,7 +96,7 @@ Along with the Environment Variables from the [Base image](https://hub.docker.co
| | Absolute HHMM, e.g. `2330` or `0415`
| | Relative +MM, i.e. how many minutes after starting the container, e.g. `+0` (immediate), `+10` (in 10 minutes), or `+90` in an hour and a half
| `DB_DUMP_DEBUG` | If set to `true`, print copious shell script messages to the container log. Otherwise only basic messages are printed.
| `DB_DUMP_TARGET` | Where to put the dump file, should be a directory. Default - `/backups` |
| `DB_DUMP_TARGET` | Where to put the dump file, should be a directory. Supports three formats |
| | Local If the value of `DB_DUMP_TARGET` starts with a `/` character, will dump to a local path, which should be volume-mounted.
| `DB_CLEANUP_TIME` | Value in minutes to delete old backups (only fired when dump freqency fires). 1440 would delete anything above 1 day old. You don't need to set this variable if you want to hold onto everything.
| `COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, or none `NONE` - Default `GZ`

View File

@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv bash
pkill bash

View File

@@ -2,7 +2,7 @@
date >/dev/null
if [ $1 != "NOW" ]; then
if [ "$1" != "NOW" ]; then
sleep 10
fi
@@ -37,7 +37,7 @@ MD5=${MD5:-TRUE}
SPLIT_DB=${SPLIT_DB:-FALSE}
TMPDIR=/tmp/backups
if [ $1 = "NOW" ]; then
if [ "$1" = "NOW" ]; then
DB_DUMP_BEGIN=+0
MANUAL=TRUE
fi
@@ -50,7 +50,7 @@ if [ "$PARALLEL_COMPRESSION" = "TRUE " ]; then
else
BZIP="bzip2"
GZIP="gzip"
XZIP=="xz"
XZIP="xz"
fi
@@ -126,7 +126,7 @@ function backup_mysql() {
function backup_influx() {
for DB in $DB_NAME; do
influxd backup -database $DB -host {DBHOST} ${TMPDIR}/${TARGET}
influxd backup -database $DB -host ${DBHOST}:${DBPORT} ${TMPDIR}/${TARGET}
generate_md5
compression
move_backup
@@ -146,7 +146,7 @@ function backup_mongo() {
function backup_pgsql() {
if [ "$SPLIT_DB" = "TRUE" ] || [ "$SPLIT_DB" = "true" ]; then
export PGPASSWORD=${DBPASS}
DATABASES=`psql -h $DBHOST -U $DBUSER -c 'COPY (SELECT datname FROM pg_database WHERE datistemplate = false) TO STDOUT;' `
DATABASES=`psql -h $DBHOST -U $DBUSER -p ${DBPORT} -c 'COPY (SELECT datname FROM pg_database WHERE datistemplate = false) TO STDOUT;' `
for db in $DATABASES; do
echo "** [db-backup] Dumping database: $db"
TARGET=pgsql_${db}_${DBHOST}_${now}.sql
@@ -157,7 +157,7 @@ function backup_pgsql() {
done
else
export PGPASSWORD=${DBPASS}
pg_dump -h ${DBHOST} -U ${DBUSER} $db > ${TMPDIR}/${TARGET}
pg_dump -h ${DBHOST} -U ${DBUSER} -p ${DBPORT} ${DBNAME} > ${TMPDIR}/${TARGET}
generate_md5
compression
move_backup