mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-21 21:33:28 +01:00
Merge pull request #43 from alwynpan/fix-optional-vars
#42 Make DB_USER and DB_PASS optional for some dbtypes; update alpine repo URI
This commit is contained in:
@@ -9,7 +9,7 @@ ENV ENABLE_CRON=FALSE \
|
|||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
||||||
apk update && \
|
apk update && \
|
||||||
apk upgrade && \
|
apk upgrade && \
|
||||||
apk add -t .db-backup-build-deps \
|
apk add -t .db-backup-build-deps \
|
||||||
@@ -19,7 +19,7 @@ RUN set -ex && \
|
|||||||
xz-dev \
|
xz-dev \
|
||||||
&& \
|
&& \
|
||||||
\
|
\
|
||||||
apk add -t .db-backup-run-deps \
|
apk add --no-cache -t .db-backup-run-deps \
|
||||||
bzip2 \
|
bzip2 \
|
||||||
influxdb \
|
influxdb \
|
||||||
mariadb-client \
|
mariadb-client \
|
||||||
@@ -33,7 +33,7 @@ RUN set -ex && \
|
|||||||
zstd \
|
zstd \
|
||||||
&& \
|
&& \
|
||||||
\
|
\
|
||||||
apk add \
|
apk add --no-cache \
|
||||||
pixz@testing \
|
pixz@testing \
|
||||||
&& \
|
&& \
|
||||||
\
|
\
|
||||||
|
|||||||
@@ -14,8 +14,44 @@ fi
|
|||||||
sanity_var DB_TYPE "Database Type"
|
sanity_var DB_TYPE "Database Type"
|
||||||
sanity_var DB_HOST "Database Host"
|
sanity_var DB_HOST "Database Host"
|
||||||
|
|
||||||
file_env 'DB_USER'
|
### Set the Database Type
|
||||||
file_env 'DB_PASS'
|
dbtype=${DB_TYPE}
|
||||||
|
|
||||||
|
case "$dbtype" in
|
||||||
|
"couch" | "couchdb" | "COUCH" | "COUCHDB" )
|
||||||
|
dbtype=couch
|
||||||
|
dbport=${DB_PORT:-5984}
|
||||||
|
file_env 'DB_USER'
|
||||||
|
file_env 'DB_PASS'
|
||||||
|
;;
|
||||||
|
"influx" | "influxdb" | "INFLUX" | "INFLUXDB" )
|
||||||
|
dbtype=influx
|
||||||
|
dbport=${DB_PORT:-8088}
|
||||||
|
file_env 'DB_USER'
|
||||||
|
file_env 'DB_PASS'
|
||||||
|
;;
|
||||||
|
"mongo" | "mongodb" | "MONGO" | "MONGODB" )
|
||||||
|
dbtype=mongo
|
||||||
|
dbport=${DB_PORT:-27017}
|
||||||
|
[[ ( -n "${DB_USER}" ) ]] && file_env 'DB_USER'
|
||||||
|
[[ ( -n "${DB_PASS}" ) ]] && file_env 'DB_PASS'
|
||||||
|
;;
|
||||||
|
"mysql" | "MYSQL" | "mariadb" | "MARIADB")
|
||||||
|
dbtype=mysql
|
||||||
|
dbport=${DB_PORT:-3306}
|
||||||
|
[[ ( -n "${DB_PASS}" ) ]] && file_env 'DB_PASS'
|
||||||
|
;;
|
||||||
|
"postgres" | "postgresql" | "pgsql" | "POSTGRES" | "POSTGRESQL" | "PGSQL" )
|
||||||
|
dbtype=pgsql
|
||||||
|
dbport=${DB_PORT:-5432}
|
||||||
|
[[ ( -n "${DB_PASS}" ) ]] && file_env 'DB_PASS'
|
||||||
|
;;
|
||||||
|
"redis" | "REDIS" )
|
||||||
|
dbtype=redis
|
||||||
|
dbport=${DB_PORT:-6379}
|
||||||
|
[[ ( -n "${DB_PASS}" ) ]] && file_env 'DB_PASS'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
### Set Defaults
|
### Set Defaults
|
||||||
BACKUP_LOCATION=${BACKUP_LOCATION:-"FILESYSTEM"}
|
BACKUP_LOCATION=${BACKUP_LOCATION:-"FILESYSTEM"}
|
||||||
@@ -27,7 +63,6 @@ DB_DUMP_TARGET=${DB_DUMP_TARGET:-/backup}
|
|||||||
dbhost=${DB_HOST}
|
dbhost=${DB_HOST}
|
||||||
dbname=${DB_NAME}
|
dbname=${DB_NAME}
|
||||||
dbpass=${DB_PASS}
|
dbpass=${DB_PASS}
|
||||||
dbtype=${DB_TYPE}
|
|
||||||
dbuser=${DB_USER}
|
dbuser=${DB_USER}
|
||||||
MD5=${MD5:-TRUE}
|
MD5=${MD5:-TRUE}
|
||||||
PARALLEL_COMPRESSION=${PARALLEL_COMPRESSION:-TRUE}
|
PARALLEL_COMPRESSION=${PARALLEL_COMPRESSION:-TRUE}
|
||||||
@@ -65,39 +100,23 @@ else
|
|||||||
zstd="zstd --rm -${COMPRESSION_LEVEL}"
|
zstd="zstd --rm -${COMPRESSION_LEVEL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### Set the Database Type
|
### Set the Database Authentication Details
|
||||||
case "$dbtype" in
|
case "$dbtype" in
|
||||||
"couch" | "couchdb" | "COUCH" | "COUCHDB" )
|
"mongo" )
|
||||||
dbtype=couch
|
|
||||||
dbport=${DB_PORT:-5984}
|
|
||||||
;;
|
|
||||||
"influx" | "influxdb" | "INFLUX" | "INFLUXDB" )
|
|
||||||
dbtype=influx
|
|
||||||
dbport=${DB_PORT:-8088}
|
|
||||||
;;
|
|
||||||
"mongo" | "mongodb" | "MONGO" | "MONGODB" )
|
|
||||||
dbtype=mongo
|
|
||||||
dbport=${DB_PORT:-27017}
|
|
||||||
[[ ( -n "${DB_USER}" ) ]] && MONGO_USER_STR=" --username ${dbuser}"
|
[[ ( -n "${DB_USER}" ) ]] && MONGO_USER_STR=" --username ${dbuser}"
|
||||||
[[ ( -n "${DB_PASS}" ) ]] && MONGO_PASS_STR=" --password ${dbpass}"
|
[[ ( -n "${DB_PASS}" ) ]] && MONGO_PASS_STR=" --password ${dbpass}"
|
||||||
[[ ( -n "${DB_NAME}" ) ]] && MONGO_DB_STR=" --db ${dbname}"
|
[[ ( -n "${DB_NAME}" ) ]] && MONGO_DB_STR=" --db ${dbname}"
|
||||||
;;
|
;;
|
||||||
"mysql" | "MYSQL" | "mariadb" | "MARIADB")
|
"mysql" )
|
||||||
dbtype=mysql
|
|
||||||
dbport=${DB_PORT:-3306}
|
|
||||||
[[ ( -n "${DB_PASS}" ) ]] && export MYSQL_PWD=${dbpass}
|
[[ ( -n "${DB_PASS}" ) ]] && export MYSQL_PWD=${dbpass}
|
||||||
;;
|
;;
|
||||||
"postgres" | "postgresql" | "pgsql" | "POSTGRES" | "POSTGRESQL" | "PGSQL" )
|
"postgres" )
|
||||||
dbtype=pgsql
|
|
||||||
dbport=${DB_PORT:-5432}
|
|
||||||
[[ ( -n "${DB_PASS}" ) ]] && POSTGRES_PASS_STR="PGPASSWORD=${dbpass}"
|
[[ ( -n "${DB_PASS}" ) ]] && POSTGRES_PASS_STR="PGPASSWORD=${dbpass}"
|
||||||
;;
|
;;
|
||||||
"redis" | "REDIS" )
|
"redis" )
|
||||||
dbtype=redis
|
|
||||||
dbport=${DB_PORT:-6379}
|
|
||||||
[[ ( -n "${DB_PASS}" ) ]] && REDIS_PASS_STR=" -a ${dbpass}"
|
[[ ( -n "${DB_PASS}" ) ]] && REDIS_PASS_STR=" -a ${dbpass}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
### Functions
|
### Functions
|
||||||
backup_couch() {
|
backup_couch() {
|
||||||
|
|||||||
Reference in New Issue
Block a user