mirror of
https://github.com/tiredofit/docker-db-backup.git
synced 2025-12-22 13:44:08 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb2a18672b | ||
|
|
5f784ed156 | ||
|
|
d9a4690ea2 | ||
|
|
baba842373 | ||
|
|
108938c17a | ||
|
|
b0b39fa8c1 | ||
|
|
fa8f43132c | ||
|
|
3f693feefc | ||
|
|
bc32b7d084 | ||
|
|
f7f6a646a0 | ||
|
|
b755497062 |
61
CHANGELOG.md
61
CHANGELOG.md
@@ -1,3 +1,64 @@
|
|||||||
|
## 3.0.15 2022-03-22 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Rework compression function
|
||||||
|
- Fix for Bzip compression failing
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.14 2022-03-22 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Rearrange Notice stating when next backup is going to start
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.13 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add compression levels to debug mode
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.12 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Throw Errors for MANUAL mode when certain other CONTAINER_* services are enabled
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.11 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Fix for Parallel Compression
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.10 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Fix for restore script not taking "custom" usernames or passwords
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.9 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Switch to using parallel versions of compression tools all the time, yet explicitly state the threads in use (1 or ++)
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.8 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add PARALLEL_COMPRESSION_THREADS environment variable to limit amount of threads when compressing - Currently autodetects however many processors are avaialable to the container
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.7 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Reverted
|
||||||
|
- Strip unused LOG directives
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0.6 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Fix for parallel compression
|
||||||
|
|
||||||
|
|
||||||
## 3.0.5 2022-03-21 <dave at tiredofit dot ca>
|
## 3.0.5 2022-03-21 <dave at tiredofit dot ca>
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
43
README.md
43
README.md
@@ -121,16 +121,16 @@ Be sure to view the following repositories to understand all the customizable op
|
|||||||
|
|
||||||
#### Container Options
|
#### Container Options
|
||||||
|
|
||||||
| Parameter | Description | Default |
|
| Parameter | Description | Default |
|
||||||
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------- |
|
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------- |
|
||||||
| `BACKUP_LOCATION` | Backup to `FILESYSTEM` or `S3` compatible services like S3, Minio, Wasabi | `FILESYSTEM` |
|
| `BACKUP_LOCATION` | Backup to `FILESYSTEM` or `S3` compatible services like S3, Minio, Wasabi | `FILESYSTEM` |
|
||||||
| `MODE` | `AUTO` mode to use internal scheduling routines or `MANUAL` to simply use this as manual backups only executed by your own means | `AUTO` |
|
| `MODE` | `AUTO` mode to use internal scheduling routines or `MANUAL` to simply use this as manual backups only executed by your own means | `AUTO` |
|
||||||
| `MANUAL_RUN_FOREVER` | `TRUE` or `FALSE` if you wish to try to make the container exit after the backup | `TRUE` |
|
| `MANUAL_RUN_FOREVER` | `TRUE` or `FALSE` if you wish to try to make the container exit after the backup | `TRUE` |
|
||||||
| `TEMP_LOCATION` | Perform Backups and Compression in this temporary directory | `/tmp/backups/` |
|
| `TEMP_LOCATION` | Perform Backups and Compression in this temporary directory | `/tmp/backups/` |
|
||||||
| `DB_AUTH` | (Mongo Only - Optional) Authentication Database | |
|
| `DB_AUTH` | (Mongo Only - Optional) Authentication Database | |
|
||||||
| `DEBUG_MODE` | If set to `true`, print copious shell script messages to the container log. Otherwise only basic messages are printed. | `FALSE` |
|
| `DEBUG_MODE` | If set to `true`, print copious shell script messages to the container log. Otherwise only basic messages are printed. | `FALSE` |
|
||||||
| `POST_SCRIPT` | Fill this variable in with a command to execute post the script backing up | |
|
| `POST_SCRIPT` | Fill this variable in with a command to execute post the script backing up | |
|
||||||
| `SPLIT_DB` | If using root as username and multiple DBs on system, set to TRUE to create Seperate DB Backups instead of all in one. | `FALSE` |
|
| `SPLIT_DB` | If using root as username and multiple DBs on system, set to TRUE to create Seperate DB Backups instead of all in one. | `FALSE` |
|
||||||
|
|
||||||
### Database Specific Options
|
### Database Specific Options
|
||||||
| Parameter | Description | Default |
|
| Parameter | Description | Default |
|
||||||
@@ -152,17 +152,18 @@ Be sure to view the following repositories to understand all the customizable op
|
|||||||
|
|
||||||
- You may need to wrap your `DB_DUMP_BEGIN` value in quotes for it to properly parse. There have been reports of backups that start with a `0` get converted into a different format which will not allow the timer to start at the correct time.
|
- You may need to wrap your `DB_DUMP_BEGIN` value in quotes for it to properly parse. There have been reports of backups that start with a `0` get converted into a different format which will not allow the timer to start at the correct time.
|
||||||
### Backup Options
|
### Backup Options
|
||||||
| Parameter | Description | Default |
|
| Parameter | Description | Default |
|
||||||
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- |
|
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | -------------- |
|
||||||
| `COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, ZSTD `ZSTD` or none `NONE` | `GZ` |
|
| `COMPRESSION` | Use either Gzip `GZ`, Bzip2 `BZ`, XZip `XZ`, ZSTD `ZSTD` or none `NONE` | `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` - | `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` - | `3` |
|
||||||
| `ENABLE_PARALLEL_COMPRESSION` | Use multiple cores when compressing backups `TRUE` or `FALSE` | `TRUE` |
|
| `ENABLE_PARALLEL_COMPRESSION` | Use multiple cores when compressing backups `TRUE` or `FALSE` | `TRUE` |
|
||||||
| `ENABLE_CHECKSUM` | Generate either a MD5 or SHA1 in Directory, `TRUE` or `FALSE` | `TRUE` |
|
| `PARALLEL_COMPRESSION_THREADS` | Maximum amount of threads to use when compressing - Integer value e.g. `8` | `autodetected` |
|
||||||
| `CHECKSUM` | Either `MD5` or `SHA1` | `MD5` |
|
| `ENABLE_CHECKSUM` | Generate either a MD5 or SHA1 in Directory, `TRUE` or `FALSE` | `TRUE` |
|
||||||
| `EXTRA_OPTS` | If you need to pass extra arguments to the backup command, add them here e.g. `--extra-command` | |
|
| `CHECKSUM` | Either `MD5` or `SHA1` | `MD5` |
|
||||||
| `MYSQL_MAX_ALLOWED_PACKET` | Max allowed packet if backing up MySQL / MariaDB | `512M` |
|
| `EXTRA_OPTS` | If you need to pass extra arguments to the backup command, add them here e.g. `--extra-command` | |
|
||||||
| `MYSQL_SINGLE_TRANSACTION` | Backup in a single transaction with MySQL / MariaDB | `TRUE` |
|
| `MYSQL_MAX_ALLOWED_PACKET` | Max allowed packet if backing up MySQL / MariaDB | `512M` |
|
||||||
| `MYSQL_STORED_PROCEDURES` | Backup stored procedures with MySQL / MariaDB | `TRUE` |
|
| `MYSQL_SINGLE_TRANSACTION` | Backup in a single transaction with MySQL / MariaDB | `TRUE` |
|
||||||
|
| `MYSQL_STORED_PROCEDURES` | Backup stored procedures with MySQL / MariaDB | `TRUE` |
|
||||||
|
|
||||||
- When using compression with MongoDB, only `GZ` compression is possible.
|
- When using compression with MongoDB, only `GZ` compression is possible.
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ services:
|
|||||||
- example-db
|
- example-db
|
||||||
volumes:
|
volumes:
|
||||||
- ./backups:/backup
|
- ./backups:/backup
|
||||||
- ./post-script.sh:/assets/custom-scripts/post-script.sh
|
#- ./post-script.sh:/assets/custom-scripts/post-script.sh
|
||||||
environment:
|
environment:
|
||||||
- DB_TYPE=mariadb
|
- DB_TYPE=mariadb
|
||||||
- DB_HOST=example-db
|
- DB_HOST=example-db
|
||||||
@@ -30,8 +30,8 @@ services:
|
|||||||
- DB_DUMP_FREQ=1440
|
- DB_DUMP_FREQ=1440
|
||||||
- DB_DUMP_BEGIN=0000
|
- DB_DUMP_BEGIN=0000
|
||||||
- DB_CLEANUP_TIME=8640
|
- DB_CLEANUP_TIME=8640
|
||||||
- CHECKSUM=MD5
|
- CHECKSUM=SHA1
|
||||||
- COMPRESSION=XZ
|
- COMPRESSION=ZSTD
|
||||||
- SPLIT_DB=FALSE
|
- SPLIT_DB=FALSE
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,13 @@ DB_DUMP_BEGIN=${DB_DUMP_BEGIN:-+0}
|
|||||||
DB_DUMP_FREQ=${DB_DUMP_FREQ:-1440}
|
DB_DUMP_FREQ=${DB_DUMP_FREQ:-1440}
|
||||||
DB_DUMP_TARGET=${DB_DUMP_TARGET:-"/backup"}
|
DB_DUMP_TARGET=${DB_DUMP_TARGET:-"/backup"}
|
||||||
ENABLE_CHECKSUM=${ENABLE_CHECKSUM:-"TRUE"}
|
ENABLE_CHECKSUM=${ENABLE_CHECKSUM:-"TRUE"}
|
||||||
ENABLE_PARALLEL_COMPRESSION={ENABLE_PARALLEL_COMPRESSION:-"TRUE"}
|
ENABLE_PARALLEL_COMPRESSION=${ENABLE_PARALLEL_COMPRESSION:-"TRUE"}
|
||||||
LOG_PATH=${LOG_PATH:-"/logs/"}
|
|
||||||
LOG_TYPE=${LOG_TYPE:-"BOTH"}
|
|
||||||
MANUAL_RUN_FOREVER=${MANUAL_RUN_FOREVER:-"TRUE"}
|
MANUAL_RUN_FOREVER=${MANUAL_RUN_FOREVER:-"TRUE"}
|
||||||
MODE=${MODE:-"AUTO"}
|
MODE=${MODE:-"AUTO"}
|
||||||
MYSQL_MAX_ALLOWED_PACKET=${MYSQL_MAX_ALLOWED_PACKET:-"512M"}
|
MYSQL_MAX_ALLOWED_PACKET=${MYSQL_MAX_ALLOWED_PACKET:-"512M"}
|
||||||
MYSQL_SINGLE_TRANSACTION=${MYSQL_SINGLE_TRANSACTION:-"TRUE"}
|
MYSQL_SINGLE_TRANSACTION=${MYSQL_SINGLE_TRANSACTION:-"TRUE"}
|
||||||
MYSQL_STORED_PROCEDURES=${MYSQL_STORED_PROCEDURES:-"TRUE"}
|
MYSQL_STORED_PROCEDURES=${MYSQL_STORED_PROCEDURES:-"TRUE"}
|
||||||
|
PARALLEL_COMPRESSION_THREADS=${PARALLEL_COMPRESSION_THREADS:-"$(nproc)"}
|
||||||
S3_CERT_SKIP_VERIFY=${S3_CERT_SKIP_VERIFY:-"TRUE"}
|
S3_CERT_SKIP_VERIFY=${S3_CERT_SKIP_VERIFY:-"TRUE"}
|
||||||
S3_PROTOCOL=${S3_PROTOCOL:-"https"}
|
S3_PROTOCOL=${S3_PROTOCOL:-"https"}
|
||||||
SIZE_VALUE=${SIZE_VALUE:-"bytes"}
|
SIZE_VALUE=${SIZE_VALUE:-"bytes"}
|
||||||
|
|||||||
@@ -1,20 +1,5 @@
|
|||||||
#!/command/with-contenv bash
|
#!/command/with-contenv bash
|
||||||
|
|
||||||
bootstrap_compression() {
|
|
||||||
### Set Compression Options
|
|
||||||
if var_true "${ENABLE_PARALLEL_COMPRESSION}" ; then
|
|
||||||
bzip="pbzip2 -${COMPRESSION_LEVEL}"
|
|
||||||
gzip="pigz -${COMPRESSION_LEVEL}"
|
|
||||||
xzip="pixz -${COMPRESSION_LEVEL}"
|
|
||||||
zstd="zstd --rm -${COMPRESSION_LEVEL}"
|
|
||||||
else
|
|
||||||
bzip="bzip2 -${COMPRESSION_LEVEL}"
|
|
||||||
gzip="gzip -${COMPRESSION_LEVEL}"
|
|
||||||
xzip="xz -${COMPRESSION_LEVEL} "
|
|
||||||
zstd="zstd --rm -${COMPRESSION_LEVEL}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bootstrap_variables() {
|
bootstrap_variables() {
|
||||||
case "${dbtype,,}" in
|
case "${dbtype,,}" in
|
||||||
couch* )
|
couch* )
|
||||||
@@ -93,7 +78,7 @@ backup_couch() {
|
|||||||
target=couch_${dbname}_${dbhost}_${now}.txt
|
target=couch_${dbname}_${dbhost}_${now}.txt
|
||||||
compression
|
compression
|
||||||
print_notice "Dumping CouchDB database: '${dbname}'"
|
print_notice "Dumping CouchDB database: '${dbname}'"
|
||||||
curl -X GET http://${dbhost}:${dbport}/${dbname}/_all_docs?include_docs=true ${dumpoutput} | $dumpoutput > ${TEMP_LOCATION}/${target}
|
curl -X GET http://${dbhost}:${dbport}/${dbname}/_all_docs?include_docs=true ${compress_cmd} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code
|
check_exit_code
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -160,8 +145,10 @@ backup_mysql() {
|
|||||||
print_notice "Dumping MySQL/MariaDB database: '${db}'"
|
print_notice "Dumping MySQL/MariaDB database: '${db}'"
|
||||||
target=mysql_${db}_${dbhost}_${now}.sql
|
target=mysql_${db}_${dbhost}_${now}.sql
|
||||||
compression
|
compression
|
||||||
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h $dbhost -P $dbport -u$dbuser ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} --databases $db | $dumpoutput > ${TEMP_LOCATION}/${target}
|
set -x
|
||||||
|
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -h $dbhost -P $dbport -u$dbuser ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} --databases $db | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
|
set +x
|
||||||
check_exit_code
|
check_exit_code
|
||||||
generate_checksum
|
generate_checksum
|
||||||
move_backup
|
move_backup
|
||||||
@@ -170,7 +157,7 @@ backup_mysql() {
|
|||||||
else
|
else
|
||||||
compression
|
compression
|
||||||
print_notice "Dumping MySQL/MariaDB database: '${DB_NAME}'"
|
print_notice "Dumping MySQL/MariaDB database: '${DB_NAME}'"
|
||||||
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -A -h $dbhost -P $dbport -u$dbuser ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} | $dumpoutput > ${TEMP_LOCATION}/${target}
|
mysqldump --max-allowed-packet=${MYSQL_MAX_ALLOWED_PACKET} -A -h $dbhost -P $dbport -u$dbuser ${single_transaction} ${stored_procedures} ${EXTRA_OPTS} | $compress_cmd > "${TEMP_LOCATION}"/"${target}"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code
|
check_exit_code
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -189,7 +176,7 @@ backup_pgsql() {
|
|||||||
print_notice "Dumping Postgresql database: $db"
|
print_notice "Dumping Postgresql database: $db"
|
||||||
target=pgsql_${db}_${dbhost}_${now}.sql
|
target=pgsql_${db}_${dbhost}_${now}.sql
|
||||||
compression
|
compression
|
||||||
pg_dump -h ${dbhost} -p ${dbport} -U ${dbuser} $db ${EXTRA_OPTS} | $dumpoutput > ${TEMP_LOCATION}/${target}
|
pg_dump -h ${dbhost} -p ${dbport} -U ${dbuser} $db ${EXTRA_OPTS} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code
|
check_exit_code
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -198,7 +185,7 @@ backup_pgsql() {
|
|||||||
else
|
else
|
||||||
compression
|
compression
|
||||||
print_notice "Dumping PostgreSQL: '${DB_NAME}'"
|
print_notice "Dumping PostgreSQL: '${DB_NAME}'"
|
||||||
pg_dump -h ${dbhost} -U ${dbuser} -p ${dbport} ${dbname} ${EXTRA_OPTS} | $dumpoutput > ${TEMP_LOCATION}/${target}
|
pg_dump -h ${dbhost} -U ${dbuser} -p ${dbport} ${dbname} ${EXTRA_OPTS} | $compress_cmd > ${TEMP_LOCATION}/${target}
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code
|
check_exit_code
|
||||||
generate_checksum
|
generate_checksum
|
||||||
@@ -225,7 +212,7 @@ backup_redis() {
|
|||||||
done
|
done
|
||||||
target_original=${target}
|
target_original=${target}
|
||||||
compression
|
compression
|
||||||
$dumpoutput "${TEMP_LOCATION}/${target_original}"
|
$compress_cmd "${TEMP_LOCATION}/${target_original}"
|
||||||
generate_checksum
|
generate_checksum
|
||||||
move_backup
|
move_backup
|
||||||
}
|
}
|
||||||
@@ -240,7 +227,7 @@ backup_sqlite3() {
|
|||||||
sqlite3 "${dbhost}" ".backup '${TEMP_LOCATION}/backup.sqlite3'"
|
sqlite3 "${dbhost}" ".backup '${TEMP_LOCATION}/backup.sqlite3'"
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
check_exit_code
|
check_exit_code
|
||||||
cat "${TEMP_LOCATION}"/backup.sqlite3 | $dumpoutput > "${TEMP_LOCATION}/${target}"
|
cat "${TEMP_LOCATION}"/backup.sqlite3 | $compress_cmd > "${TEMP_LOCATION}/${target}"
|
||||||
generate_checksum
|
generate_checksum
|
||||||
move_backup
|
move_backup
|
||||||
}
|
}
|
||||||
@@ -338,30 +325,38 @@ check_exit_code() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compression() {
|
compression() {
|
||||||
|
if var_false "${ENABLE_PARALLEL_COMPRESSION}" ; then
|
||||||
|
PARALLEL_COMPRESSION_THREADS=1
|
||||||
|
fi
|
||||||
|
|
||||||
case "${COMPRESSION,,}" in
|
case "${COMPRESSION,,}" in
|
||||||
gz* )
|
gz* )
|
||||||
print_notice "Compressing backup with gzip"
|
print_notice "Compressing backup with gzip"
|
||||||
|
print_debug "Compression Level: '${COMPRESSION_LEVEL}'"
|
||||||
target=${target}.gz
|
target=${target}.gz
|
||||||
dumpoutput="$gzip "
|
compress_cmd="pigz -${COMPRESSION_LEVEL} -p ${PARALLEL_COMPRESSION_THREADS} "
|
||||||
;;
|
;;
|
||||||
bz* )
|
bz* )
|
||||||
print_notice "Compressing backup with bzip2"
|
print_notice "Compressing backup with bzip2"
|
||||||
|
print_debug "Compression Level: '${COMPRESSION_LEVEL}'"
|
||||||
target=${target}.bz2
|
target=${target}.bz2
|
||||||
dumpoutput="$bzip "
|
compress_cmd="pbzip2 -${COMPRESSION_LEVEL} -p${PARALLEL_COMPRESSION_THREADS} "
|
||||||
;;
|
;;
|
||||||
xz* )
|
xz* )
|
||||||
print_notice "Compressing backup with xzip"
|
print_notice "Compressing backup with xzip"
|
||||||
|
print_debug "Compression Level: '${COMPRESSION_LEVEL}'"
|
||||||
target=${target}.xz
|
target=${target}.xz
|
||||||
dumpoutput="$xzip "
|
compress_cmd="pixz -${COMPRESSION_LEVEL} -p ${PARALLEL_COMPRESSION_THREADS} "
|
||||||
;;
|
;;
|
||||||
zst* )
|
zst* )
|
||||||
print_notice "Compressing backup with zstd"
|
print_notice "Compressing backup with zstd"
|
||||||
|
print_debug "Compression Level: '${COMPRESSION_LEVEL}'"
|
||||||
target=${target}.zst
|
target=${target}.zst
|
||||||
dumpoutput="$zstd "
|
compress_cmd="zstd --rm -${COMPRESSION_LEVEL} -T${PARALLEL_COMPRESSION_THREADS}"
|
||||||
;;
|
;;
|
||||||
"none" | "false")
|
"none" | "false")
|
||||||
print_notice "Not compressing backups"
|
print_notice "Not compressing backups"
|
||||||
dumpoutput="cat "
|
compress_cmd="cat "
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@@ -458,7 +453,7 @@ setup_mode() {
|
|||||||
if [ "${MODE,,}" = "auto" ] || [ ${MODE,,} = "default" ] ; then
|
if [ "${MODE,,}" = "auto" ] || [ ${MODE,,} = "default" ] ; then
|
||||||
print_debug "Running in Auto / Default Mode - Letting Image control scheduling"
|
print_debug "Running in Auto / Default Mode - Letting Image control scheduling"
|
||||||
else
|
else
|
||||||
print_info "Running in Manual mode - Execute 'backup_now' to run a manual backup"
|
print_info "Running in Manual mode - Execute 'backup_now' or '/etc/services.available/10-db-backup/run' to perform a manual backup"
|
||||||
service_stop 10-db-backup
|
service_stop 10-db-backup
|
||||||
if var_true "${MANUAL_RUN_FOREVER}" ; then
|
if var_true "${MANUAL_RUN_FOREVER}" ; then
|
||||||
mkdir -p /etc/services.d/99-run_forever
|
mkdir -p /etc/services.d/99-run_forever
|
||||||
@@ -470,6 +465,19 @@ do
|
|||||||
done
|
done
|
||||||
EOF
|
EOF
|
||||||
chmod +x /etc/services.d/99-run_forever/run
|
chmod +x /etc/services.d/99-run_forever/run
|
||||||
|
else
|
||||||
|
if var_true "${CONTAINER_ENABLE_SCHEDULING}" ; then
|
||||||
|
print_error "Manual / Exit after execution mode doesn't work with 'CONTAINER_ENABLE_SCHEDULING=TRUE'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if var_true "${CONTAINER_ENABLE_MONITORING}" ; then
|
||||||
|
print_error "Manual / Exit after execution mode doesn't work with 'CONTAINER_ENABLE_MONITORING=TRUE'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if var_true "${CONTAINER_ENABLE_LOGSHIPPING}" ; then
|
||||||
|
print_error "Manual / Exit after execution mode doesn't work with 'CONTAINER_ENABLE_LOGSHIPPING=TRUE'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -4,14 +4,14 @@ source /assets/functions/00-container
|
|||||||
source /assets/functions/10-db-backup
|
source /assets/functions/10-db-backup
|
||||||
source /assets/defaults/10-db-backup
|
source /assets/defaults/10-db-backup
|
||||||
PROCESS_NAME="db-backup"
|
PROCESS_NAME="db-backup"
|
||||||
|
CONTAINER_LOG_LEVEL=DEBUG
|
||||||
|
|
||||||
bootstrap_compression
|
|
||||||
bootstrap_variables
|
bootstrap_variables
|
||||||
|
|
||||||
if [ "${MODE,,}" = "manual" ] ; then
|
if [ "${MODE,,}" = "manual" ] ; then
|
||||||
DB_DUMP_BEGIN=+0
|
DB_DUMP_BEGIN=+0
|
||||||
manual=TRUE
|
manual=TRUE
|
||||||
silent s6-svc -d /var/run/legacy-services/10-db-backup
|
print_debug "Detected Manual Mode"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${1,,}" in
|
case "${1,,}" in
|
||||||
@@ -25,7 +25,7 @@ case "${1,,}" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
### Container Startup
|
### Container Startup
|
||||||
print_debug "Backup routines Initialized on $(date)"
|
print_debug "Backup routines Initialized on $(date +'%Y-%m-%d %H:%M:%S')"
|
||||||
|
|
||||||
### Wait for Next time to start backup
|
### Wait for Next time to start backup
|
||||||
case "${1,,}" in
|
case "${1,,}" in
|
||||||
@@ -33,7 +33,7 @@ case "${1,,}" in
|
|||||||
:
|
:
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
if [ "${manual,,}" = "true" ]; then
|
if [ "${manual,,}" != "true" ]; then
|
||||||
current_time=$(date +"%s")
|
current_time=$(date +"%s")
|
||||||
today=$(date +"%Y%m%d")
|
today=$(date +"%Y%m%d")
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ while true; do
|
|||||||
exit ${exit_code};
|
exit ${exit_code};
|
||||||
else
|
else
|
||||||
### Go back to sleep until next backup time
|
### Go back to sleep until next backup time
|
||||||
sleep $(($DB_DUMP_FREQ*60-backup_total_time))
|
|
||||||
print_notice "Sleeping for another $(($DB_DUMP_FREQ*60-backup_total_time)) seconds. Waking up at $(date -d@"$(( $(date +%s)+$(($DB_DUMP_FREQ*60-backup_total_time))))" +"%Y-%m-%d %T %Z") "
|
print_notice "Sleeping for another $(($DB_DUMP_FREQ*60-backup_total_time)) seconds. Waking up at $(date -d@"$(( $(date +%s)+$(($DB_DUMP_FREQ*60-backup_total_time))))" +"%Y-%m-%d %T %Z") "
|
||||||
|
sleep $(($DB_DUMP_FREQ*60-backup_total_time))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -697,9 +697,9 @@ EOF
|
|||||||
c* )
|
c* )
|
||||||
counter=1
|
counter=1
|
||||||
q_dbuser=" "
|
q_dbuser=" "
|
||||||
while [[ $q_dbname = *" "* ]]; do
|
while [[ $q_dbuser = *" "* ]]; do
|
||||||
if [ $counter -gt 1 ] ; then print_error "DB Usernames can't have spaces in them, please re-enter." ; fi ;
|
if [ $counter -gt 1 ] ; then print_error "DB Usernames can't have spaces in them, please re-enter." ; fi ;
|
||||||
read -e -p "$(echo -e ${clg}** ${cdgy}What DB User do you wish to use:\ ${coff})" q_dbname
|
read -e -p "$(echo -e ${clg}** ${cdgy}What DB User do you wish to use:\ ${coff})" q_dbuser
|
||||||
(( counter+=1 ))
|
(( counter+=1 ))
|
||||||
done
|
done
|
||||||
r_dbuser=${q_dbuser}
|
r_dbuser=${q_dbuser}
|
||||||
@@ -766,9 +766,9 @@ EOF
|
|||||||
c* )
|
c* )
|
||||||
counter=1
|
counter=1
|
||||||
q_dbpass=" "
|
q_dbpass=" "
|
||||||
while [[ $q_dbname = *" "* ]]; do
|
while [[ $q_dbpass = *" "* ]]; do
|
||||||
if [ $counter -gt 1 ] ; then print_error "DB Passwords can't have spaces in them, please re-enter." ; fi ;
|
if [ $counter -gt 1 ] ; then print_error "DB Passwords can't have spaces in them, please re-enter." ; fi ;
|
||||||
read -e -p "$(echo -e ${clg}** ${cdgy}What DB Password do you wish to use:\ ${coff})" q_dbname
|
read -e -p "$(echo -e ${clg}** ${cdgy}What DB Password do you wish to use:\ ${coff})" q_dbpass
|
||||||
(( counter+=1 ))
|
(( counter+=1 ))
|
||||||
done
|
done
|
||||||
r_dbpass=${q_dbpass}
|
r_dbpass=${q_dbpass}
|
||||||
|
|||||||
Reference in New Issue
Block a user