mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 13:23:12 +01:00
1.1 - Added CouchDB
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user