Skip to content

Commit 5cf00a8

Browse files
committedNov 11, 2023
Release 4.0.6 - See CHANGELOG.md
1 parent 2bc7300 commit 5cf00a8

File tree

2 files changed

+69
-15
lines changed

2 files changed

+69
-15
lines changed
 

‎CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 4.0.6 2023-11-10 <dave at tiredofit dot ca>
2+
3+
### Added
4+
- Add additional DEBUG_ statements
5+
6+
### Changed
7+
- Fix issue with Influx DB not properly detecting the correct version
8+
9+
110
## 4.0.5 2023-11-10 <dave at tiredofit dot ca>
211

312
### Added

‎install/assets/functions/10-db-backup

+60-15
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ bootstrap_variables() {
237237
transform_backup_instance_variable "${backup_instance_number}" USER backup_job_db_user
238238

239239
backup_job_backup_begin=$(echo "${backup_job_backup_begin}" | sed -e "s|'||g" -e 's|"||g')
240+
if var_true "${DEBUG_BACKUP_INSTANCE_VARIABLE}" ; then cat <<EOF
241+
## BEGIN Variable Dump $(TZ=${TIMEZONE} date)
242+
243+
$(cat ${backup_instance_vars})
244+
245+
## END
246+
EOF
247+
fi
240248
rm -rf "${backup_instance_vars}"
241249
}
242250

@@ -315,7 +323,7 @@ bootstrap_variables() {
315323
## Check is Variable is Defined
316324
## Usage: check_var transformed_varname real_varname "Description"
317325
output_off
318-
print_debug "Looking for existence of $2 environment variable"
326+
print_debug "[parse_variables] Looking for existence of $2 environment variable"
319327
if [ ! -v "$1" ]; then
320328
print_error "No '$3' Entered! - Set '\$$2' environment variable - Halting Backup Number ${v_instance}"
321329
s6-svc -d /var/run/s6/legacy-services/dbbackup-"${v_instance}"
@@ -470,15 +478,16 @@ backup_couch() {
470478
backup_influx() {
471479
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug on; fi
472480
if [ "${backup_job_db_name,,}" = "all" ] ; then
473-
write_log debug "Preparing to back up everything"
481+
write_log debug "[backup_influx] Preparing to back up everything"
474482
db_names=justbackupeverything
475483
else
476484
db_names=$(echo "${backup_job_db_name}" | tr ',' '\n')
477485
fi
478486
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug off; fi
479487

480-
case "${backup_job_db_influx_version,,}" in
488+
case "${backup_job_influx_version,,}" in
481489
1 )
490+
print_debug "[backup_influx] Influx DB Version 1 selected"
482491
for db in ${db_names}; do
483492
prepare_dbbackup
484493
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug on; fi
@@ -507,6 +516,7 @@ backup_influx() {
507516
done
508517
;;
509518
2 )
519+
print_debug "[backup_influx] Influx DB Version 2 selected"
510520
for db in ${db_names}; do
511521
prepare_dbbackup
512522
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug on; fi
@@ -1049,6 +1059,7 @@ compression() {
10491059

10501060
case "${backup_job_compression,,}" in
10511061
bz* )
1062+
print_debug "[compression] Selected BZIP"
10521063
compress_cmd="${play_fair} pbzip2 -q -${backup_job_compression_level} -p${backup_job_parallel_compression_threads} "
10531064
compression_type="bzip2"
10541065
dir_compress_cmd=${compress_cmd}
@@ -1057,6 +1068,7 @@ compression() {
10571068
backup_job_filename=${backup_job_filename}.bz2
10581069
;;
10591070
gz* )
1071+
print_debug "[compression] Selected GZIP"
10601072
compress_cmd="${play_fair} pigz -q -${backup_job_compression_level} -p ${backup_job_parallel_compression_threads} ${gz_rsyncable}"
10611073
compression_type="gzip"
10621074
extension=".gz"
@@ -1065,6 +1077,7 @@ compression() {
10651077
backup_job_filename=${backup_job_filename}.gz
10661078
;;
10671079
xz* )
1080+
print_debug "[compression] Selected XZIP"
10681081
compress_cmd="${play_fair} pixz -${backup_job_compression_level} -p ${backup_job_parallel_compression_threads} "
10691082
compression_type="xzip"
10701083
dir_compress_cmd=${compress_cmd}
@@ -1073,6 +1086,7 @@ compression() {
10731086
backup_job_filename=${backup_job_filename}.xz
10741087
;;
10751088
zst* )
1089+
print_debug "[compression] Selected ZSTD"
10761090
compress_cmd="${play_fair} zstd -q -q --rm -${backup_job_compression_level} -T${backup_job_parallel_compression_threads} ${gz_rsyncable}"
10771091
compression_type="zstd"
10781092
dir_compress_cmd=${compress_cmd}
@@ -1121,9 +1135,10 @@ create_schedulers() {
11211135
backup() {
11221136
bootstrap_variables upgrade BACKUP
11231137
local backup_instances=$(printenv | sort | grep -c "^DB[0-9]._HOST")
1138+
print_debug "[create_schedulers] Found '${backup_instances}' DB_HOST instances"
11241139
if [ -n "${DB_HOST}" ] && [ "${backup_instances}" ]; then
11251140
backup_instances=1;
1126-
print_debug "Detected using old DB_ variables"
1141+
print_debug "[create_schedulers] Detected using old DB_ variables"
11271142
fi
11281143

11291144
for (( instance = 01; instance <= backup_instances; )) ; do
@@ -1199,7 +1214,7 @@ file_encryption() {
11991214
if var_true "${DEBUG_FILE_ENCRYPTION}" ; then debug on; fi
12001215
if var_true "${backup_job_encrypt}" ; then
12011216
if [ "${exit_code}" = "0" ] ; then
1202-
print_debug "Encrypting"
1217+
print_debug "[file_encryption] Encrypting"
12031218
output_off
12041219
if [ -n "${backup_job_encrypt_passphrase}" ] && [ -n "${backup_job_encrypt_pubkey}" ]; then
12051220
print_error "Can't encrypt as both ENCRYPT_PASSPHRASE and ENCRYPT_PUBKEY exist!"
@@ -1220,6 +1235,7 @@ file_encryption() {
12201235
fi
12211236
fi
12221237
if [ -f "${TEMP_PATH}"/"${backup_job_filename}".gpg ]; then
1238+
print_debug "[file_encryption] Deleting original file"
12231239
rm -rf "${TEMP_PATH:?}"/"${backup_job_filename:?}"
12241240
backup_job_filename="${backup_job_filename}.gpg"
12251241

@@ -1395,23 +1411,23 @@ EOF
13951411
for notification_type in $notification_types ; do
13961412
case "${notification_type,,}" in
13971413
"custom" )
1398-
print_debug "Sending Notification via custom"
1414+
print_debug "[notify] Sending Notification via custom"
13991415
notification_custom "${1}" "${2}" "${3}" "${4}" "${5}"
14001416
;;
14011417
"email" | "mail" )
1402-
print_debug "Sending Notification via email"
1418+
print_debug "[notify] Sending Notification via email"
14031419
notification_email "${1}" "${2}" "${3}" "${4}" "${5}"
14041420
;;
14051421
"matrix" )
1406-
print_debug "Sending Notification via Matrix"
1422+
print_debug "[notify] Sending Notification via Matrix"
14071423
notification_matrix "${1}" "${2}" "${3}" "${4}" "${5}"
14081424
;;
14091425
"mattermost" )
1410-
print_debug "Sending Notification via Mattermost"
1426+
print_debug "[notify] Sending Notification via Mattermost"
14111427
notification_mattermost "${1}" "${2}" "${3}" "${4}" "${5}"
14121428
;;
14131429
"rocketchat" )
1414-
print_debug "Sending Notification via Rocketchat"
1430+
print_debug "[notify] Sending Notification via Rocketchat"
14151431
notification_rocketchat "${1}" "${2}" "${3}" "${4}" "${5}"
14161432
;;
14171433
* )
@@ -1454,8 +1470,37 @@ move_dbbackup() {
14541470
write_log debug "Moving backup to filesystem"
14551471
run_as_user mkdir -p "${backup_job_filesystem_path}"
14561472
if [ "${backup_job_checksum,,}" != "none" ] ; then run_as_user mv "${TEMP_PATH}"/*."${checksum_extension}" "${backup_job_filesystem_path}"/ ; fi
1473+
if var_true "${DEBUG_MOVE_DBBACKUP}"; then
1474+
cat <<EOF
1475+
## BEGIN Before Moving file from TEMP_PATH $(TZ=${TIMEZONE} date)
1476+
##
1477+
1478+
$(ls -l "${TEMP_PATH}"/*)
1479+
1480+
## END
1481+
EOF
1482+
fi
14571483
run_as_user mv "${TEMP_PATH}"/"${backup_job_filename}" "${backup_job_filesystem_path}"/"${backup_job_filename}"
14581484
move_exit_code=$?
1485+
if var_true "${DEBUG_MOVE_DBBACKUP}"; then
1486+
cat <<EOF
1487+
## BEGIN After Moving file from TEMP_PATH $(TZ=${TIMEZONE} date)
1488+
##
1489+
1490+
$(ls -l "${TEMP_PATH}"/*)
1491+
1492+
## END
1493+
1494+
## BEGIN After Moving file to _FILESYSTEM_PATH $(TZ=${TIMEZONE} date)
1495+
##
1496+
1497+
$(ls -l "${backup_job_filesystem_path}"/*)
1498+
1499+
## END
1500+
1501+
EOF
1502+
fi
1503+
14591504
if var_true "${backup_job_create_latest_symlink}" ; then
14601505
run_as_user ln -sfr "${backup_job_filesystem_path}"/"${backup_job_filename}" "${backup_job_filesystem_path}"/latest-"${backup_job_filename_base}"
14611506
fi
@@ -1661,7 +1706,7 @@ process_limiter() {
16611706
}
16621707

16631708
run_as_user() {
1664-
s6-setuidgid "${DBBACKUP_USER}" $@
1709+
sudo -u "${DBBACKUP_USER}" $@
16651710
}
16661711

16671712
setup_mode() {
@@ -1894,18 +1939,18 @@ timer() {
18941939
;;
18951940
datetime)
18961941
time_begin=$(date -d "${backup_job_backup_begin}" +%s)
1897-
print_debug "BACKUP_BEGIN time = ${time_begin}"
1942+
print_debug "[timer] [datetime] BACKUP_BEGIN time = ${time_begin}"
18981943
time_wait=$(( time_begin - time_current ))
1899-
print_debug "Difference in seconds: ${time_wait}"
1944+
print_debug "[timer] [datetime] Difference in seconds: ${time_wait}"
19001945

19011946
if (( ${time_wait} < 0 )); then
19021947
time_wait=$(( (${time_wait} + (${backup_job_backup_interval} - 1)) / (${backup_job_backup_interval} * 60) ))
19031948
time_wait=$(( ${time_wait} * -1 ))
1904-
print_debug "Difference in seconds (rounded) time_wait is in the past : ${time_wait}"
1949+
print_debug "[timer] [datetime] Difference in seconds (rounded) time_wait is in the past : ${time_wait}"
19051950
fi
19061951

19071952
time_future=$(( time_current + time_wait ))
1908-
print_debug "Future execution time = ${time_future}"
1953+
print_debug "[timer] [datetime] Future execution time = ${time_future}"
19091954
;;
19101955
job)
19111956
case "${2}" in

0 commit comments

Comments
 (0)
Please sign in to comment.