mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-22 21:53:42 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b808b35624 | ||
|
|
e060aeb0e5 | ||
|
|
03c16cc582 | ||
|
|
e45d916b00 | ||
|
|
eb0ee61662 | ||
|
|
8e737eb579 | ||
|
|
5d2043a603 | ||
|
|
89fe251321 | ||
|
|
353b1af7b4 |
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,4 +1,20 @@
|
|||||||
## 2.6.1 2021-02-19 <jwillmer@github>
|
## 2.8.0 2021-08-27 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Alpine 3.14 Base
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Fix for syntax error in 2.7.0 Release (Credit the1ts@github)
|
||||||
|
- Cleanup image and leftover cache with AWS CLI installation
|
||||||
|
|
||||||
|
|
||||||
|
## 2.7.0 2021-06-17 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- MongoDB Authentication Database support (DB_AUTH)
|
||||||
|
|
||||||
|
|
||||||
|
## 2.6.1 2021-06-08 <jwillmer@github>
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Fix for Issue #14 - SPLIT_DB=TRUE was not working for Postgres DB server
|
- Fix for Issue #14 - SPLIT_DB=TRUE was not working for Postgres DB server
|
||||||
|
|||||||
14
Dockerfile
14
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
FROM tiredofit/alpine:3.13
|
FROM tiredofit/alpine:3.14
|
||||||
|
|
||||||
### Set Environment Variables
|
### Set Environment Variables
|
||||||
ENV MSSQL_VERSION=17.5.2.1-1 \
|
ENV MSSQL_VERSION=17.5.2.1-1 \
|
||||||
@@ -16,6 +16,7 @@ RUN set -ex && \
|
|||||||
bzip2-dev \
|
bzip2-dev \
|
||||||
git \
|
git \
|
||||||
libarchive-dev \
|
libarchive-dev \
|
||||||
|
py3-pip \
|
||||||
xz-dev \
|
xz-dev \
|
||||||
&& \
|
&& \
|
||||||
\
|
\
|
||||||
@@ -29,6 +30,7 @@ RUN set -ex && \
|
|||||||
pigz \
|
pigz \
|
||||||
postgresql \
|
postgresql \
|
||||||
postgresql-client \
|
postgresql-client \
|
||||||
|
python3 \
|
||||||
redis \
|
redis \
|
||||||
sqlite \
|
sqlite \
|
||||||
xz \
|
xz \
|
||||||
@@ -55,13 +57,15 @@ RUN set -ex && \
|
|||||||
--sysconfdir=/etc \
|
--sysconfdir=/etc \
|
||||||
--localstatedir=/var \
|
--localstatedir=/var \
|
||||||
&& \
|
&& \
|
||||||
make && \
|
make && \
|
||||||
make install && \
|
make install && \
|
||||||
\
|
pip3 install --upgrade pip && \
|
||||||
|
pip3 install awscli && \
|
||||||
|
\
|
||||||
### Cleanup
|
### Cleanup
|
||||||
apk del .db-backup-build-deps && \
|
apk del .db-backup-build-deps && \
|
||||||
rm -rf /usr/src/* && \
|
rm -rf /usr/src/* && \
|
||||||
rm -rf /tmp/* /var/cache/apk/*
|
rm -rf /root/.cache /tmp/* /var/cache/apk/*
|
||||||
|
|
||||||
### S6 Setup
|
### S6 Setup
|
||||||
ADD install /
|
ADD install /
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ Be sure to view the following repositories to understand all the customizable op
|
|||||||
| `BACKUP_LOCATION` | Backup to `FILESYSTEM` or `S3` compatible services like S3, Minio, Wasabi - Default `FILESYSTEM` |
|
| `BACKUP_LOCATION` | Backup to `FILESYSTEM` or `S3` compatible services like S3, Minio, Wasabi - Default `FILESYSTEM` |
|
||||||
| `COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, ZSTD `ZSTD` or none `NONE` - Default `GZ` |
|
| `COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, ZSTD `ZSTD` or none `NONE` - Default `GZ` |
|
||||||
| `COMPRESSION_LEVEL` | Numberical value of what level of compression to use, most allow `1` to `9` except for `ZSTD` which allows for `1` to `19` - Default `3` |
|
| `COMPRESSION_LEVEL` | Numberical value of what level of compression to use, most allow `1` to `9` except for `ZSTD` which allows for `1` to `19` - Default `3` |
|
||||||
|
| `DB_AUTH` | (Mongo Only - Optional) Authentication Database |
|
||||||
| `DB_TYPE` | Type of DB Server to backup `couch` `influx` `mysql` `pgsql` `mongo` `redis` `sqlite3` |
|
| `DB_TYPE` | Type of DB Server to backup `couch` `influx` `mysql` `pgsql` `mongo` `redis` `sqlite3` |
|
||||||
| `DB_HOST` | Server Hostname e.g. `mariadb`. For `sqlite3`, full path to DB file e.g. `/backup/db.sqlite3` |
|
| `DB_HOST` | Server Hostname e.g. `mariadb`. For `sqlite3`, full path to DB file e.g. `/backup/db.sqlite3` |
|
||||||
| `DB_NAME` | Schema Name e.g. `database` |
|
| `DB_NAME` | Schema Name e.g. `database` |
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ case "$dbtype" in
|
|||||||
[[ ( -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}"
|
||||||
|
[[ ( -n "${DB_AUTH}" ) ]] && MONGO_AUTH_STR=" --authenticationDatabase ${DB_AUTH}"
|
||||||
;;
|
;;
|
||||||
"mysql" )
|
"mysql" )
|
||||||
[[ ( -n "${DB_PASS}" ) ]] && export MYSQL_PWD=${dbpass}
|
[[ ( -n "${DB_PASS}" ) ]] && export MYSQL_PWD=${dbpass}
|
||||||
@@ -164,7 +165,7 @@ backup_mongo() {
|
|||||||
target=${dbtype}_${dbname}_${dbhost}_${now}.archivegz
|
target=${dbtype}_${dbname}_${dbhost}_${now}.archivegz
|
||||||
mongo_compression="--gzip"
|
mongo_compression="--gzip"
|
||||||
fi
|
fi
|
||||||
mongodump --archive=${tmpdir}/${target} ${mongo_compression} --host ${dbhost} --port ${dbport} ${MONGO_USER_STR}${MONGO_PASS_STR}${MONGO_DB_STR} ${EXTRA_OPTS}
|
mongodump --archive=${tmpdir}/${target} ${mongo_compression} --host ${dbhost} --port ${dbport} ${MONGO_USER_STR}${MONGO_PASS_STR}${MONGO_AUTH_STR}${MONGO_DB_STR} ${EXTRA_OPTS}
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
cd ${tmpdir}
|
cd ${tmpdir}
|
||||||
generate_md5
|
generate_md5
|
||||||
@@ -413,34 +414,10 @@ move_backup() {
|
|||||||
mv ${tmpdir}/"${target}" "${DB_DUMP_TARGET}"/"${target}"
|
mv ${tmpdir}/"${target}" "${DB_DUMP_TARGET}"/"${target}"
|
||||||
;;
|
;;
|
||||||
"S3" | "s3" | "MINIO" | "minio" )
|
"S3" | "s3" | "MINIO" | "minio" )
|
||||||
s3_content_type="application/octet-stream"
|
export AWS_ACCESS_KEY_ID=${S3_KEY_ID}
|
||||||
if [ "$S3_URI_STYLE" = "VIRTUALHOST" ] || [ "$S3_URI_STYLE" = "VHOST" ] || [ "$S3_URI_STYLE" = "virtualhost" ] || [ "$S3_URI_STYLE" = "vhost" ] ; then
|
export AWS_SECRET_ACCESS_KEY=${S3_KEY_SECRET}
|
||||||
s3_url="${S3_BUCKET}.${S3_HOST}"
|
export AWS_DEFAULT_REGION=ap-northeast-2
|
||||||
else
|
aws s3 cp ${tmpdir}/${target} s3://${S3_BUCKET}/${S3_PATH}/${target}
|
||||||
s3_url="${S3_HOST}/${S3_BUCKET}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if var_true "$MD5" ; then
|
|
||||||
s3_date="$(LC_ALL=C date -u +"%a, %d %b %Y %X %z")"
|
|
||||||
s3_md5="$(libressl md5 -binary < "${tmpdir}/${target}.md5" | base64)"
|
|
||||||
sig="$(printf "PUT\n$s3_md5\n${s3_content_type}\n$s3_date\n/$S3_BUCKET/$S3_PATH/${target}.md5" | libressl sha1 -binary -hmac "${S3_KEY_SECRET}" | base64)"
|
|
||||||
print_debug "Uploading ${target}.md5 to S3"
|
|
||||||
curl -T "${tmpdir}/${target}.md5" "${S3_PROTOCOL}"://"${s3_url}"/"${S3_PATH}"/"${target}".md5 \
|
|
||||||
-H "Date: $date" \
|
|
||||||
-H "Authorization: AWS ${S3_KEY_ID}:$sig" \
|
|
||||||
-H "Content-Type: ${s3_content_type}" \
|
|
||||||
-H "Content-MD5: ${s3_md5}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
s3_date="$(LC_ALL=C date -u +"%a, %d %b %Y %X %z")"
|
|
||||||
s3_md5="$(libressl md5 -binary < "${tmpdir}/${target}" | base64)"
|
|
||||||
sig="$(printf "PUT\n$s3_md5\n${s3_content_type}\n$s3_date\n/$S3_BUCKET/$S3_PATH/${target}" | libressl sha1 -binary -hmac "${S3_KEY_SECRET}" | base64)"
|
|
||||||
print_debug "Uploading ${target} to S3"
|
|
||||||
curl -T ${tmpdir}/"${target}" "${S3_PROTOCOL}"://"${s3_url}"/"${S3_PATH}"/"${target}" \
|
|
||||||
-H "Date: $s3_date" \
|
|
||||||
-H "Authorization: AWS ${S3_KEY_ID}:$sig" \
|
|
||||||
-H "Content-Type: ${s3_content_type}" \
|
|
||||||
-H "Content-MD5: ${s3_md5}"
|
|
||||||
|
|
||||||
rm -rf ${tmpdir}/*.md5
|
rm -rf ${tmpdir}/*.md5
|
||||||
rm -rf ${tmpdir}/"${target}"
|
rm -rf ${tmpdir}/"${target}"
|
||||||
|
|||||||
Reference in New Issue
Block a user