mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-22 21:53:42 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f207f375cc | ||
|
|
88b58bffc5 | ||
|
|
738f7fad25 | ||
|
|
8c4733bf7f | ||
|
|
be4d8c0747 | ||
|
|
a13849df0a |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,3 +1,28 @@
|
|||||||
|
## 2.4.0 2020-12-07 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Switch back to packges for Postgresql (now 13.1)
|
||||||
|
|
||||||
|
|
||||||
|
## 2.3.2 2020-11-14 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Reapply S6-Overlay into filesystem as Postgresql build is removing S6 files due to edge containing S6 overlay
|
||||||
|
|
||||||
|
|
||||||
|
## 2.3.1 2020-11-11 <bambi73@github>
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Multiple Influx DB's not being backed up correctly
|
||||||
|
|
||||||
|
## 2.3.0 2020-10-15 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Microsoft SQL Server support (experimental)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Compiled Postgresql 13 from source to backup psql/13 hosts
|
||||||
|
|
||||||
## 2.2.2 2020-09-22 <tpansino@github>
|
## 2.2.2 2020-09-22 <tpansino@github>
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
11
Dockerfile
11
Dockerfile
@@ -1,13 +1,13 @@
|
|||||||
FROM tiredofit/alpine:edge
|
FROM tiredofit/alpine:edge
|
||||||
LABEL maintainer="Dave Conroy (dave at tiredofit dot ca)"
|
|
||||||
|
|
||||||
### Set Environment Variables
|
### Set Environment Variables
|
||||||
ENV ENABLE_CRON=FALSE \
|
ENV MSSQL_VERSION=17.5.2.1-1 \
|
||||||
|
ENABLE_CRON=FALSE \
|
||||||
ENABLE_SMTP=FALSE \
|
ENABLE_SMTP=FALSE \
|
||||||
ENABLE_ZABBIX=TRUE \
|
ENABLE_ZABBIX=TRUE \
|
||||||
ZABBIX_HOSTNAME=db-backup
|
ZABBIX_HOSTNAME=db-backup
|
||||||
|
|
||||||
### Dependencies
|
### Dependencies
|
||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
echo "@testing https://dl-cdn.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 && \
|
||||||
@@ -37,6 +37,11 @@ RUN set -ex && \
|
|||||||
pixz@testing \
|
pixz@testing \
|
||||||
&& \
|
&& \
|
||||||
\
|
\
|
||||||
|
cd /usr/src && \
|
||||||
|
curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_${MSSQL_VERSION}_amd64.apk && \
|
||||||
|
curl -O https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/mssql-tools_${MSSQL_VERSION}_amd64.apk && \
|
||||||
|
echo y | apk add --allow-untrusted msodbcsql17_${MSSQL_VERSION}_amd64.apk mssql-tools_${MSSQL_VERSION}_amd64.apk && \
|
||||||
|
\
|
||||||
mkdir -p /usr/src/pbzip2 && \
|
mkdir -p /usr/src/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 && \
|
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 /usr/src/pbzip2 && \
|
cd /usr/src/pbzip2 && \
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ case "$dbtype" in
|
|||||||
dbport=${DB_PORT:-3306}
|
dbport=${DB_PORT:-3306}
|
||||||
[[ ( -n "${DB_PASS}" ) || ( -n "${DB_PASS_FILE}" ) ]] && file_env 'DB_PASS'
|
[[ ( -n "${DB_PASS}" ) || ( -n "${DB_PASS_FILE}" ) ]] && file_env 'DB_PASS'
|
||||||
;;
|
;;
|
||||||
|
"mssql" | "MSSQL" | "microsoftsql" | "MICROSOFTSQL")
|
||||||
|
dbtype=mssql
|
||||||
|
dbport=${DB_PORT:-1433}
|
||||||
|
;;
|
||||||
"postgres" | "postgresql" | "pgsql" | "POSTGRES" | "POSTGRESQL" | "PGSQL" )
|
"postgres" | "postgresql" | "pgsql" | "POSTGRES" | "POSTGRESQL" | "PGSQL" )
|
||||||
dbtype=pgsql
|
dbtype=pgsql
|
||||||
dbport=${DB_PORT:-5432}
|
dbport=${DB_PORT:-5432}
|
||||||
@@ -128,6 +132,42 @@ backup_couch() {
|
|||||||
move_backup
|
move_backup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
backup_influx() {
|
||||||
|
if [ "${COMPRESSION}" = "NONE" ] || [ "${COMPRESSION}" = "none" ] || [ "${COMPRESSION}" = "FALSE" ] || [ "${COMPRESSION}" = "false" ] ; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
print_notice "Compressing InfluxDB backup with gzip"
|
||||||
|
influx_compression="-portable"
|
||||||
|
fi
|
||||||
|
for DB in $DB_NAME; do
|
||||||
|
target=influx_${DB}_${dbhost}_${now}
|
||||||
|
influxd backup ${influx_compression} -database $DB -host ${dbhost}:${dbport} ${tmpdir}/${target}
|
||||||
|
exit_code=$?
|
||||||
|
generate_md5
|
||||||
|
move_backup
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
backup_mongo() {
|
||||||
|
if [ "${COMPRESSION}" = "NONE" ] || [ "${COMPRESSION}" = "none" ] || [ "${COMPRESSION}" = "FALSE" ] || [ "${COMPRESSION}" = "false" ] ; then
|
||||||
|
target=${dbtype}_${dbname}_${dbhost}_${now}.archive
|
||||||
|
else
|
||||||
|
print_notice "Compressing MongoDB backup with gzip"
|
||||||
|
target=${dbtype}_${dbname}_${dbhost}_${now}.archivegz
|
||||||
|
mongo_compression="--gzip"
|
||||||
|
fi
|
||||||
|
mongodump --archive=${tmpdir}/${target} ${mongo_compression} --host ${dbhost} --port ${dbport} ${MONGO_USER_STR}${MONGO_PASS_STR}${MONGO_DB_STR} ${EXTRA_OPTS}
|
||||||
|
exit_code=$?
|
||||||
|
cd ${tmpdir}
|
||||||
|
generate_md5
|
||||||
|
move_backup
|
||||||
|
}
|
||||||
|
|
||||||
|
backup_mssql() {
|
||||||
|
target=mssql_${dbname}_${dbhost}_${now}.bak
|
||||||
|
/opt/mssql-tools/bin/sqlcmd -E -C -S ${dbhost}\,${dbport} -U ${dbuser} -P ${dbpass} –Q "BACKUP DATABASE \[${dbname}\] TO DISK = N'${tmpdir}/${target}' WITH NOFORMAT, NOINIT, NAME = '${dbname}-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
|
||||||
|
}
|
||||||
|
|
||||||
backup_mysql() {
|
backup_mysql() {
|
||||||
if var_true "$SPLIT_DB" ; then
|
if var_true "$SPLIT_DB" ; then
|
||||||
DATABASES=$(mysql -h ${dbhost} -P $dbport -u$dbuser --batch -e "SHOW DATABASES;" | grep -v Database|grep -v schema)
|
DATABASES=$(mysql -h ${dbhost} -P $dbport -u$dbuser --batch -e "SHOW DATABASES;" | grep -v Database|grep -v schema)
|
||||||
@@ -152,36 +192,6 @@ backup_mysql() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_influx() {
|
|
||||||
if [ "${COMPRESSION}" = "NONE" ] || [ "${COMPRESSION}" = "none" ] || [ "${COMPRESSION}" = "FALSE" ] || [ "${COMPRESSION}" = "false" ] ; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
print_notice "Compressing InfluxDB backup with gzip"
|
|
||||||
influx_compression="-portable"
|
|
||||||
fi
|
|
||||||
for DB in $DB_NAME; do
|
|
||||||
influxd backup ${influx_compression} -database $DB -host ${dbhost}:${dbport} ${tmpdir}/${target}
|
|
||||||
exit_code=$?
|
|
||||||
generate_md5
|
|
||||||
move_backup
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
backup_mongo() {
|
|
||||||
if [ "${COMPRESSION}" = "NONE" ] || [ "${COMPRESSION}" = "none" ] || [ "${COMPRESSION}" = "FALSE" ] || [ "${COMPRESSION}" = "false" ] ; then
|
|
||||||
target=${dbtype}_${dbname}_${dbhost}_${now}.archive
|
|
||||||
else
|
|
||||||
print_notice "Compressing MongoDB backup with gzip"
|
|
||||||
target=${dbtype}_${dbname}_${dbhost}_${now}.archivegz
|
|
||||||
mongo_compression="--gzip"
|
|
||||||
fi
|
|
||||||
mongodump --archive=${tmpdir}/${target} ${mongo_compression} --host ${dbhost} --port ${dbport} ${MONGO_USER_STR}${MONGO_PASS_STR}${MONGO_DB_STR} ${EXTRA_OPTS}
|
|
||||||
exit_code=$?
|
|
||||||
cd ${tmpdir}
|
|
||||||
generate_md5
|
|
||||||
move_backup
|
|
||||||
}
|
|
||||||
|
|
||||||
backup_pgsql() {
|
backup_pgsql() {
|
||||||
if var_true $SPLIT_DB ; then
|
if var_true $SPLIT_DB ; then
|
||||||
export PGPASSWORD=${dbpass}
|
export PGPASSWORD=${dbpass}
|
||||||
@@ -268,6 +278,14 @@ check_availability() {
|
|||||||
(( COUNTER+=5 ))
|
(( COUNTER+=5 ))
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
"mssql" )
|
||||||
|
COUNTER=0
|
||||||
|
while ! (nc -z ${dbhost} ${dbport}) ; do
|
||||||
|
sleep 5
|
||||||
|
(( COUNTER+=5 ))
|
||||||
|
print_warn "MSSQL Host '${dbhost}' is not accessible, retrying.. ($COUNTER seconds so far)"
|
||||||
|
done
|
||||||
|
;;
|
||||||
"pgsql" )
|
"pgsql" )
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
export PGPASSWORD=${dbpass}
|
export PGPASSWORD=${dbpass}
|
||||||
@@ -434,6 +452,10 @@ print_debug "Backup routines Initialized on $(date)"
|
|||||||
check_availability
|
check_availability
|
||||||
backup_influx
|
backup_influx
|
||||||
;;
|
;;
|
||||||
|
"mssql" )
|
||||||
|
check_availability
|
||||||
|
backup_mssql
|
||||||
|
;;
|
||||||
"mysql" )
|
"mysql" )
|
||||||
check_availability
|
check_availability
|
||||||
backup_mysql
|
backup_mysql
|
||||||
|
|||||||
Reference in New Issue
Block a user