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 | |
|---|---|---|---|
|
|
494f742cb0 | ||
|
|
e7b9a36745 | ||
|
|
28c7058f37 | ||
|
|
6f15c77a0f | ||
|
|
4e04e31d84 | ||
|
|
f3fad4a893 |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,3 +1,28 @@
|
|||||||
|
## 3.5.4 2022-10-13 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Fix for Influx DB 1 backups when compression enabled
|
||||||
|
|
||||||
|
|
||||||
|
## 3.5.3 2022-10-12 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Remove build dependencies for blobxfer making image size smaller
|
||||||
|
- Remove silencing commands limiting Postgres backups from working without DEBUG_MODE=TRUE
|
||||||
|
|
||||||
|
|
||||||
|
## 3.5.2 2022-10-11 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Update Influxdb client to 2.4.0 (jauderho@github)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.5.1 2022-10-11 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Tighten up cleanup routines to not call blobxfer unless absolutely necessary
|
||||||
|
|
||||||
|
|
||||||
## 3.5.0 2022-10-10 <dave at tiredofit dot ca>
|
## 3.5.0 2022-10-10 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ LABEL maintainer="Dave Conroy (github.com/tiredofit)"
|
|||||||
|
|
||||||
### Set Environment Variables
|
### Set Environment Variables
|
||||||
|
|
||||||
ENV INFLUX2_VERSION=2.2.1 \
|
ENV INFLUX2_VERSION=2.4.0 \
|
||||||
MSSQL_VERSION=18.0.1.1-1 \
|
MSSQL_VERSION=18.0.1.1-1 \
|
||||||
CONTAINER_ENABLE_MESSAGING=FALSE \
|
CONTAINER_ENABLE_MESSAGING=FALSE \
|
||||||
CONTAINER_ENABLE_MONITORING=TRUE \
|
CONTAINER_ENABLE_MONITORING=TRUE \
|
||||||
@@ -20,6 +20,10 @@ RUN set -ex && \
|
|||||||
bzip2-dev \
|
bzip2-dev \
|
||||||
git \
|
git \
|
||||||
libarchive-dev \
|
libarchive-dev \
|
||||||
|
libressl-dev \
|
||||||
|
libffi-dev \
|
||||||
|
python3-dev \
|
||||||
|
py3-pip \
|
||||||
xz-dev \
|
xz-dev \
|
||||||
&& \
|
&& \
|
||||||
\
|
\
|
||||||
@@ -69,7 +73,6 @@ RUN set -ex && \
|
|||||||
make && \
|
make && \
|
||||||
make install && \
|
make install && \
|
||||||
\
|
\
|
||||||
apk add gcc build-base libressl-dev libffi-dev python3-dev py3-pip && \
|
|
||||||
pip3 install blobxfer && \
|
pip3 install blobxfer && \
|
||||||
\
|
\
|
||||||
### Cleanup
|
### Cleanup
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ backup_influx() {
|
|||||||
influxd backup ${influx_compression} ${bucket} -portable -host ${DB_HOST}:${DB_PORT} ${EXTRA_OPTS} "${TEMP_LOCATION}"/"${target_dir}"
|
influxd backup ${influx_compression} ${bucket} -portable -host ${DB_HOST}:${DB_PORT} ${EXTRA_OPTS} "${TEMP_LOCATION}"/"${target_dir}"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code $target_dir
|
check_exit_code $target_dir
|
||||||
print_notice "Creating archive file of '${target_dir}' with tar ${compresion_string}"
|
print_notice "Creating archive file of '${target_dir}' with tar ${compression_string}"
|
||||||
tar cf - "${TEMP_LOCATION}"/"${target_dir}" | $dir_compress_cmd > "${TEMP_LOCATION}"/"${target_dir}".tar"${extension}"
|
tar cf - "${TEMP_LOCATION}"/"${target_dir}" | $dir_compress_cmd > "${TEMP_LOCATION}"/"${target_dir}".tar"${extension}"
|
||||||
target=influx_${db}_${DB_HOST#*//}_${now}.tar${extension}
|
target=influx_${db}_${DB_HOST#*//}_${now}.tar${extension}
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -214,7 +214,7 @@ backup_mysql() {
|
|||||||
compression
|
compression
|
||||||
pre_dbbackup $db
|
pre_dbbackup $db
|
||||||
print_notice "Dumping MySQL/MariaDB database: '${db}' ${compression_string}"
|
print_notice "Dumping MySQL/MariaDB database: '${db}' ${compression_string}"
|
||||||
silent mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h ${DB_HOST} -P ${DB_PORT} -u${DB_USER} ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} --databases $db | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
|
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h ${DB_HOST} -P ${DB_PORT} -u${DB_USER} ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} --databases $db | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code $target
|
check_exit_code $target
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -228,7 +228,7 @@ backup_mysql() {
|
|||||||
compression
|
compression
|
||||||
pre_dbbackup all
|
pre_dbbackup all
|
||||||
print_notice "Dumping all MySQL / MariaDB databases: '$(echo ${db_names} | xargs | tr ' ' ',')' ${compression_string}"
|
print_notice "Dumping all MySQL / MariaDB databases: '$(echo ${db_names} | xargs | tr ' ' ',')' ${compression_string}"
|
||||||
silent mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h ${DB_HOST} -P ${DB_PORT} -u${DB_USER} ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} --databases $(echo ${db_names} | xargs) | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
|
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h ${DB_HOST} -P ${DB_PORT} -u${DB_USER} ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} --databases $(echo ${db_names} | xargs) | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code $target
|
check_exit_code $target
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -263,7 +263,7 @@ backup_pgsql() {
|
|||||||
compression
|
compression
|
||||||
pre_dbbackup $db
|
pre_dbbackup $db
|
||||||
print_notice "Dumping PostgresSQL database: '${db}' ${compression_string}"
|
print_notice "Dumping PostgresSQL database: '${db}' ${compression_string}"
|
||||||
silent pg_dump -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USER} $db ${EXTRA_OPTS} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
pg_dump -h ${DB_HOST} -p ${DB_PORT} -U ${DB_USER} $db ${EXTRA_OPTS} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code $target
|
check_exit_code $target
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -285,7 +285,7 @@ backup_pgsql() {
|
|||||||
for x_db_name in ${tmp_db_names} ; do
|
for x_db_name in ${tmp_db_names} ; do
|
||||||
pgexclude_arg=$(echo ${pgexclude_arg} --exclude-database=${x_db_name})
|
pgexclude_arg=$(echo ${pgexclude_arg} --exclude-database=${x_db_name})
|
||||||
done
|
done
|
||||||
silent pg_dumpall -h ${DB_HOST} -U ${DB_USER} -p ${DB_PORT} ${pgexclude_arg} ${EXTRA_OPTS} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
pg_dumpall -h ${DB_HOST} -U ${DB_USER} -p ${DB_PORT} ${pgexclude_arg} ${EXTRA_OPTS} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code $target
|
check_exit_code $target
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -460,16 +460,17 @@ cleanup_old_data() {
|
|||||||
if [ -n "${DB_CLEANUP_TIME}" ]; then
|
if [ -n "${DB_CLEANUP_TIME}" ]; then
|
||||||
if [ "${master_exit_code}" != 1 ]; then
|
if [ "${master_exit_code}" != 1 ]; then
|
||||||
case "${BACKUP_LOCATION,,}" in
|
case "${BACKUP_LOCATION,,}" in
|
||||||
"file" | "filesystem" | "blobxfer" )
|
"file" | "filesystem" )
|
||||||
print_info "Cleaning up old backups"
|
print_info "Cleaning up old backups on filesystem"
|
||||||
mkdir -p "${DB_DUMP_TARGET}"
|
mkdir -p "${DB_DUMP_TARGET}"
|
||||||
find "${DB_DUMP_TARGET}"/ -mmin +"${DB_CLEANUP_TIME}" -iname "*" -exec rm {} \;
|
find "${DB_DUMP_TARGET}"/ -mmin +"${DB_CLEANUP_TIME}" -iname "*" -exec rm {} \;
|
||||||
|
if [ "${BACKUP_LOCATION,,}" = "blobxfer" ] ; then
|
||||||
print_info "Cleaning up old backups on S3 storage with blobxfer"
|
print_info "Syncing changes via blobxfer"
|
||||||
blobxfer upload --mode file --remote-path ${BLOBXFER_REMOTE_PATH} --local-path ${DB_DUMP_TARGET} --delete --delete-only
|
silent blobxfer upload --mode file --remote-path ${BLOBXFER_REMOTE_PATH} --local-path ${DB_DUMP_TARGET} --delete --delete-only
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"s3" | "minio" )
|
"s3" | "minio" )
|
||||||
print_info "Cleaning up old backups"
|
print_info "Cleaning up old backups on S3 storage"
|
||||||
aws ${PARAM_AWS_ENDPOINT_URL} s3 ls s3://${S3_BUCKET}/${S3_PATH} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS} | grep " DIR " -v | grep " PRE " -v | while read -r s3_file; do
|
aws ${PARAM_AWS_ENDPOINT_URL} s3 ls s3://${S3_BUCKET}/${S3_PATH} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS} | grep " DIR " -v | grep " PRE " -v | while read -r s3_file; do
|
||||||
s3_createdate=$(echo $s3_file | awk {'print $1" "$2'})
|
s3_createdate=$(echo $s3_file | awk {'print $1" "$2'})
|
||||||
s3_createdate=$(date -d "$s3_createdate" "+%s")
|
s3_createdate=$(date -d "$s3_createdate" "+%s")
|
||||||
@@ -652,7 +653,7 @@ move_dbbackup() {
|
|||||||
mv "${TEMP_LOCATION}"/*."${checksum_extension}" "${DB_DUMP_TARGET}"/
|
mv "${TEMP_LOCATION}"/*."${checksum_extension}" "${DB_DUMP_TARGET}"/
|
||||||
mv "${TEMP_LOCATION}"/"${target}" "${DB_DUMP_TARGET}"/"${target}"
|
mv "${TEMP_LOCATION}"/"${target}" "${DB_DUMP_TARGET}"/"${target}"
|
||||||
|
|
||||||
blobxfer upload --mode file --remote-path ${BLOBXFER_REMOTE_PATH} --local-path ${DB_DUMP_TARGET}
|
silent blobxfer upload --mode file --remote-path ${BLOBXFER_REMOTE_PATH} --local-path ${DB_DUMP_TARGET}
|
||||||
|
|
||||||
rm -rf "${TEMP_LOCATION}"/*."${checksum_extension}"
|
rm -rf "${TEMP_LOCATION}"/*."${checksum_extension}"
|
||||||
rm -rf "${TEMP_LOCATION}"/"${target}"
|
rm -rf "${TEMP_LOCATION}"/"${target}"
|
||||||
|
|||||||
Reference in New Issue
Block a user