From 6fe85eeaf7380b4e4058ac0a7262e637ada67d53 Mon Sep 17 00:00:00 2001 From: Dave Conroy Date: Wed, 13 Sep 2017 20:30:47 -0700 Subject: [PATCH] 1.1 - Added CouchDB --- CHANGELOG.md | 5 ++++- README.md | 4 ++-- install/etc/s6/services/10-db-backup/run | 28 +++++++++++++++++++----- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46eb37f..75951d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.1 - 2017-09-14 - dave at tiredofit dot ca +* Added CouchDB + ## 1.0 - 2017-09-14 - dave at tiredofit dot ca * Initial Release - +* Alpine:Edge diff --git a/README.md b/README.md index 7ab01eb..a1e0820 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This will build a container for backing up multiple type of DB Servers -Currently backs up InfluxDB, MySQL, MongoDB Postgres, Redis, Rethink servers. +Currently backs up CouchDB, InfluxDB, MySQL, MongoDB Postgres, Redis, Rethink servers. * dump to local filesystem * select database user and password @@ -79,7 +79,7 @@ Along with the Environment Variables from the [Base image](https://hub.docker.co | Parameter | Description | |-----------|-------------| -| `DB_TYPE` | Type of DB Server to backup `influx` `mysql` `pgsql` `mongo` `redis` `rethink` +| `DB_TYPE` | Type of DB Server to backup `couch` `influx` `mysql` `pgsql` `mongo` `redis` `rethink` | `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. diff --git a/install/etc/s6/services/10-db-backup/run b/install/etc/s6/services/10-db-backup/run index 46c6bda..572c26c 100755 --- a/install/etc/s6/services/10-db-backup/run +++ b/install/etc/s6/services/10-db-backup/run @@ -37,6 +37,10 @@ TMPDIR=/tmp/backups ### Set the Database Type case "DBTYPE" in + "couch" | "couchdb" | "COUCH" | "COUCHDB" ) + DBTYPE=couch + DBPORT=${DB_PORT:-5984} + ;; "influx" | "influxdb" | "INFLUX" | "INFLUXDB" ) DBTYPE=influx DBPORT=${DB_PORT:-8088} @@ -71,6 +75,15 @@ TMPDIR=/tmp/backups esac ### Functions +function backup_couch() { + TARGET=couch_${DBNAME}_${DBHOST}_${now}.txt + curl -X GET http://${DBHOST}:${DBPORT}/${DBNAME}/ all docs? include docs=true >${TMPDIR}/${TARGET} + generate_md5 + compression + move_backup + done +} + function backup_mysql() { if [ "$SPLIT_DB" = "TRUE" ] || [ "$SPLIT_DB" = "true" ]; then DATABASES=`mysql -h $DBHOST -u$DBUSER -p$DBPASS --batch -e "SHOW DATABASES;" | grep -v Database|grep -v schema` @@ -223,23 +236,26 @@ echo '** [db-backup] Initialized at at '$(date) ### Take a Dump case "DBTYPE" in + "couch" ) + backup_couch + ;; "influx" ) - function_backup_influx + backup_influx ;; "mysql" ) - function_backup_mysql + backup_mysql ;; "mongo" ) - function_backup_mongo + backup_mongo ;; "pgsql" ) - function_backup_pgsql + backup_pgsql ;; "redis" ) - function_backup_redis + backup_redis ;; "rethink" ) - function_backup_rethink + backup_rethink ;; esac