@@ -237,6 +237,14 @@ bootstrap_variables() {
237
237
transform_backup_instance_variable "${backup_instance_number}" USER backup_job_db_user
238
238
239
239
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
240
248
rm -rf "${backup_instance_vars}"
241
249
}
242
250
@@ -315,7 +323,7 @@ bootstrap_variables() {
315
323
## Check is Variable is Defined
316
324
## Usage: check_var transformed_varname real_varname "Description"
317
325
output_off
318
- print_debug "Looking for existence of $2 environment variable"
326
+ print_debug "[parse_variables] Looking for existence of $2 environment variable"
319
327
if [ ! -v "$1" ]; then
320
328
print_error "No '$3' Entered! - Set '\$$2' environment variable - Halting Backup Number ${v_instance}"
321
329
s6-svc -d /var/run/s6/legacy-services/dbbackup-"${v_instance}"
@@ -470,15 +478,16 @@ backup_couch() {
470
478
backup_influx() {
471
479
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug on; fi
472
480
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"
474
482
db_names=justbackupeverything
475
483
else
476
484
db_names=$(echo "${backup_job_db_name}" | tr ',' '\n')
477
485
fi
478
486
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug off; fi
479
487
480
- case "${backup_job_db_influx_version ,,}" in
488
+ case "${backup_job_influx_version ,,}" in
481
489
1 )
490
+ print_debug "[backup_influx] Influx DB Version 1 selected"
482
491
for db in ${db_names}; do
483
492
prepare_dbbackup
484
493
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug on; fi
@@ -507,6 +516,7 @@ backup_influx() {
507
516
done
508
517
;;
509
518
2 )
519
+ print_debug "[backup_influx] Influx DB Version 2 selected"
510
520
for db in ${db_names}; do
511
521
prepare_dbbackup
512
522
if var_true "${DEBUG_BACKUP_INFLUX}" ; then debug on; fi
@@ -1049,6 +1059,7 @@ compression() {
1049
1059
1050
1060
case "${backup_job_compression,,}" in
1051
1061
bz* )
1062
+ print_debug "[compression] Selected BZIP"
1052
1063
compress_cmd="${play_fair} pbzip2 -q -${backup_job_compression_level} -p${backup_job_parallel_compression_threads} "
1053
1064
compression_type="bzip2"
1054
1065
dir_compress_cmd=${compress_cmd}
@@ -1057,6 +1068,7 @@ compression() {
1057
1068
backup_job_filename=${backup_job_filename}.bz2
1058
1069
;;
1059
1070
gz* )
1071
+ print_debug "[compression] Selected GZIP"
1060
1072
compress_cmd="${play_fair} pigz -q -${backup_job_compression_level} -p ${backup_job_parallel_compression_threads} ${gz_rsyncable}"
1061
1073
compression_type="gzip"
1062
1074
extension=".gz"
@@ -1065,6 +1077,7 @@ compression() {
1065
1077
backup_job_filename=${backup_job_filename}.gz
1066
1078
;;
1067
1079
xz* )
1080
+ print_debug "[compression] Selected XZIP"
1068
1081
compress_cmd="${play_fair} pixz -${backup_job_compression_level} -p ${backup_job_parallel_compression_threads} "
1069
1082
compression_type="xzip"
1070
1083
dir_compress_cmd=${compress_cmd}
@@ -1073,6 +1086,7 @@ compression() {
1073
1086
backup_job_filename=${backup_job_filename}.xz
1074
1087
;;
1075
1088
zst* )
1089
+ print_debug "[compression] Selected ZSTD"
1076
1090
compress_cmd="${play_fair} zstd -q -q --rm -${backup_job_compression_level} -T${backup_job_parallel_compression_threads} ${gz_rsyncable}"
1077
1091
compression_type="zstd"
1078
1092
dir_compress_cmd=${compress_cmd}
@@ -1121,9 +1135,10 @@ create_schedulers() {
1121
1135
backup() {
1122
1136
bootstrap_variables upgrade BACKUP
1123
1137
local backup_instances=$(printenv | sort | grep -c "^DB[0-9]._HOST")
1138
+ print_debug "[create_schedulers] Found '${backup_instances}' DB_HOST instances"
1124
1139
if [ -n "${DB_HOST}" ] && [ "${backup_instances}" ]; then
1125
1140
backup_instances=1;
1126
- print_debug "Detected using old DB_ variables"
1141
+ print_debug "[create_schedulers] Detected using old DB_ variables"
1127
1142
fi
1128
1143
1129
1144
for (( instance = 01; instance <= backup_instances; )) ; do
@@ -1199,7 +1214,7 @@ file_encryption() {
1199
1214
if var_true "${DEBUG_FILE_ENCRYPTION}" ; then debug on; fi
1200
1215
if var_true "${backup_job_encrypt}" ; then
1201
1216
if [ "${exit_code}" = "0" ] ; then
1202
- print_debug "Encrypting"
1217
+ print_debug "[file_encryption] Encrypting"
1203
1218
output_off
1204
1219
if [ -n "${backup_job_encrypt_passphrase}" ] && [ -n "${backup_job_encrypt_pubkey}" ]; then
1205
1220
print_error "Can't encrypt as both ENCRYPT_PASSPHRASE and ENCRYPT_PUBKEY exist!"
@@ -1220,6 +1235,7 @@ file_encryption() {
1220
1235
fi
1221
1236
fi
1222
1237
if [ -f "${TEMP_PATH}"/"${backup_job_filename}".gpg ]; then
1238
+ print_debug "[file_encryption] Deleting original file"
1223
1239
rm -rf "${TEMP_PATH:?}"/"${backup_job_filename:?}"
1224
1240
backup_job_filename="${backup_job_filename}.gpg"
1225
1241
@@ -1395,23 +1411,23 @@ EOF
1395
1411
for notification_type in $notification_types ; do
1396
1412
case "${notification_type,,}" in
1397
1413
"custom" )
1398
- print_debug "Sending Notification via custom"
1414
+ print_debug "[notify] Sending Notification via custom"
1399
1415
notification_custom "${1}" "${2}" "${3}" "${4}" "${5}"
1400
1416
;;
1401
1417
"email" | "mail" )
1402
- print_debug "Sending Notification via email"
1418
+ print_debug "[notify] Sending Notification via email"
1403
1419
notification_email "${1}" "${2}" "${3}" "${4}" "${5}"
1404
1420
;;
1405
1421
"matrix" )
1406
- print_debug "Sending Notification via Matrix"
1422
+ print_debug "[notify] Sending Notification via Matrix"
1407
1423
notification_matrix "${1}" "${2}" "${3}" "${4}" "${5}"
1408
1424
;;
1409
1425
"mattermost" )
1410
- print_debug "Sending Notification via Mattermost"
1426
+ print_debug "[notify] Sending Notification via Mattermost"
1411
1427
notification_mattermost "${1}" "${2}" "${3}" "${4}" "${5}"
1412
1428
;;
1413
1429
"rocketchat" )
1414
- print_debug "Sending Notification via Rocketchat"
1430
+ print_debug "[notify] Sending Notification via Rocketchat"
1415
1431
notification_rocketchat "${1}" "${2}" "${3}" "${4}" "${5}"
1416
1432
;;
1417
1433
* )
@@ -1454,8 +1470,37 @@ move_dbbackup() {
1454
1470
write_log debug "Moving backup to filesystem"
1455
1471
run_as_user mkdir -p "${backup_job_filesystem_path}"
1456
1472
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
1457
1483
run_as_user mv "${TEMP_PATH}"/"${backup_job_filename}" "${backup_job_filesystem_path}"/"${backup_job_filename}"
1458
1484
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
+
1459
1504
if var_true "${backup_job_create_latest_symlink}" ; then
1460
1505
run_as_user ln -sfr "${backup_job_filesystem_path}"/"${backup_job_filename}" "${backup_job_filesystem_path}"/latest-"${backup_job_filename_base}"
1461
1506
fi
@@ -1661,7 +1706,7 @@ process_limiter() {
1661
1706
}
1662
1707
1663
1708
run_as_user() {
1664
- s6-setuidgid "${DBBACKUP_USER}" $@
1709
+ sudo -u "${DBBACKUP_USER}" $@
1665
1710
}
1666
1711
1667
1712
setup_mode() {
@@ -1894,18 +1939,18 @@ timer() {
1894
1939
;;
1895
1940
datetime)
1896
1941
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}"
1898
1943
time_wait=$(( time_begin - time_current ))
1899
- print_debug "Difference in seconds: ${time_wait}"
1944
+ print_debug "[timer] [datetime] Difference in seconds: ${time_wait}"
1900
1945
1901
1946
if (( ${time_wait} < 0 )); then
1902
1947
time_wait=$(( (${time_wait} + (${backup_job_backup_interval} - 1)) / (${backup_job_backup_interval} * 60) ))
1903
1948
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}"
1905
1950
fi
1906
1951
1907
1952
time_future=$(( time_current + time_wait ))
1908
- print_debug "Future execution time = ${time_future}"
1953
+ print_debug "[timer] [datetime] Future execution time = ${time_future}"
1909
1954
;;
1910
1955
job)
1911
1956
case "${2}" in
0 commit comments