Skip to content

Commit d1e98d9

Browse files
committed
Release 3.3.0 - See CHANGELOG.md
1 parent 0920b67 commit d1e98d9

File tree

4 files changed

+62
-34
lines changed

4 files changed

+62
-34
lines changed

CHANGELOG.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
## 3.2.6 2022-04-25 <dave at tiredofit dot ca>
1+
## 3.3.0 2022-04-30 <dave at tiredofit dot ca>
22

3-
### Changed
4-
- Stop throwing error trying to move blank file if checksums are not enabled
5-
6-
7-
## 3.2.5 2022-04-23 <dave at tiredofit dot ca>
8-
9-
### Changed
10-
- Fix for restore still not working with DB_PORT variable
3+
### Added
4+
- Ability to auto clean old S3 / Minio Hosts like what occurs on filesysten
5+
- Alert user how to turn off Zabbix Monitoring if fails
6+
- Allow Zabbix Monitoring to work with S3
7+
- Silence some more compression statements
8+
### Changed
9+
- Fix for Redis not backing up properly
10+
- Start sending checksums for S3 Outputs
11+
- Cleanup some code functions
12+
- FIx Container Log Level always in DEBUG
1113

1214

1315
## 3.2.4 2022-04-21 <dave at tiredofit dot ca>

install/assets/functions/10-db-backup

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,15 @@ backup_redis() {
279279
pre_dbbackup
280280
print_notice "Dumping Redis - Flushing Redis Cache First"
281281
target=redis_all_${DB_HOST,,}_${now}.rdb
282-
echo bgsave | redis-cli -h ${DB_HOST} -p ${DB_PORT} ${REDIS_PASS_STR} --rdb ${TEMP_LOCATION}/${target} ${EXTRA_OPTS}
282+
echo bgsave | silent redis-cli -h ${DB_HOST} -p ${DB_PORT} ${REDIS_PASS_STR} --rdb ${TEMP_LOCATION}/${target} ${EXTRA_OPTS}
283283
sleep 10
284284
try=5
285285
while [ $try -gt 0 ] ; do
286286
saved=$(echo 'info Persistence' | redis-cli -h ${DB_HOST} -p ${DB_PORT} ${REDIS_PASS_STR} | awk '/rdb_bgsave_in_progress:0/{print "saved"}')
287287
ok=$(echo 'info Persistence' | redis-cli -h ${DB_HOST} -p ${DB_PORT} ${REDIS_PASS_STR} | awk '/rdb_last_bgsave_status:ok/{print "ok"}')
288288
if [[ "$saved" = "saved" ]] && [[ "$ok" = "ok" ]]; then
289289
print_notice "Redis Backup Complete"
290+
exit_code=0
290291
break
291292
fi
292293
try=$((try - 1))
@@ -296,6 +297,7 @@ backup_redis() {
296297
target_original=${target}
297298
compression
298299
$compress_cmd "${TEMP_LOCATION}/${target_original}"
300+
check_exit_code $target
299301
generate_checksum
300302
move_dbbackup
301303
post_dbbackup all
@@ -430,11 +432,31 @@ check_exit_code() {
430432
cleanup_old_data() {
431433
if [ -n "${DB_CLEANUP_TIME}" ]; then
432434
if [ "${master_exit_code}" != 1 ]; then
433-
print_info "Cleaning up old backups"
434-
mkdir -p "${DB_DUMP_TARGET}"
435-
find "${DB_DUMP_TARGET}"/ -mmin +"${DB_CLEANUP_TIME}" -iname "*" -exec rm {} \;
435+
case "${BACKUP_LOCATION,,}" in
436+
"file" | "filesystem" )
437+
print_info "Cleaning up old backups"
438+
mkdir -p "${DB_DUMP_TARGET}"
439+
find "${DB_DUMP_TARGET}"/ -mmin +"${DB_CLEANUP_TIME}" -iname "*" -exec rm {} \;
440+
;;
441+
"s3" | "minio" )
442+
print_info "Cleaning up old backups"
443+
aws ${PARAM_AWS_ENDPOINT_URL} s3 ls s3://${S3_BUCKET}/${S3_PATH} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS} | grep " DIR " -v | while read -r s3_file; do
444+
s3_createdate=$(echo $s3_file | awk {'print $1" "$2'})
445+
s3_createdate=$(date -d "$s3_createdate" "+%s")
446+
s3_olderthan=$(echo $(( $(date +%s)-${DB_CLEANUP_TIME}*60 )))
447+
if [[ $s3_createdate -le $s3_olderthan ]] ; then
448+
s3_filename=$(echo $s3_file | awk {'print $4'})
449+
if [ $s3_filename != "" ] ; then
450+
print_debug "Deleting $s3_filename"
451+
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 rm s3://${S3_BUCKET}/${S3_PATH}/${s3_filename} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
452+
fi
453+
fi
454+
455+
done
456+
;;
457+
esac
436458
else
437-
print_info "Skipping Cleaning up old backups because there were errors in backing up"
459+
print_error "Skipping Cleaning up old backups because there were errors in backing up"
438460
fi
439461
fi
440462
}
@@ -446,31 +468,31 @@ compression() {
446468

447469
case "${COMPRESSION,,}" in
448470
gz* )
449-
compress_cmd="pigz -${COMPRESSION_LEVEL} -p ${PARALLEL_COMPRESSION_THREADS} "
471+
compress_cmd="silent pigz -${COMPRESSION_LEVEL} -p ${PARALLEL_COMPRESSION_THREADS} "
450472
compression_type="gzip"
451473
extension=".gz"
452474
dir_compress_cmd=${compress_cmd}
453475
target_dir=${target}
454476
target=${target}.gz
455477
;;
456478
bz* )
457-
compress_cmd="pbzip2 -${COMPRESSION_LEVEL} -p${PARALLEL_COMPRESSION_THREADS} "
479+
compress_cmd="silent pbzip2 -${COMPRESSION_LEVEL} -p${PARALLEL_COMPRESSION_THREADS} "
458480
compression_type="bzip2"
459481
dir_compress_cmd=${compress_cmd}
460482
extension=".bz2"
461483
target_dir=${target}
462484
target=${target}.bz2
463485
;;
464486
xz* )
465-
compress_cmd="pixz -${COMPRESSION_LEVEL} -p ${PARALLEL_COMPRESSION_THREADS} "
487+
compress_cmd="silent pixz -${COMPRESSION_LEVEL} -p ${PARALLEL_COMPRESSION_THREADS} "
466488
compression_type="xzip"
467489
dir_compress_cmd=${compress_cmd}
468490
extension=".xz"
469491
target_dir=${target}
470492
target=${target}.xz
471493
;;
472494
zst* )
473-
compress_cmd="zstd --rm -${COMPRESSION_LEVEL} -T${PARALLEL_COMPRESSION_THREADS} "
495+
compress_cmd="silent zstd --rm -${COMPRESSION_LEVEL} -T${PARALLEL_COMPRESSION_THREADS} "
474496
compression_type="zstd"
475497
dir_compress_cmd=${compress_cmd}
476498
extension=".zst"
@@ -506,12 +528,12 @@ create_archive() {
506528
print_notice "Creating archive file of '${target_dir}' with tar ${compresion_string}"
507529
tar cf - "${TEMP_LOCATION}"/"${target_dir}" | $dir_compress_cmd > "${TEMP_LOCATION}"/"${target_dir}".tar"${extension}"
508530
else
509-
print_warn "Skipping creating archive file because backup did not complete successfully"
531+
print_error "Skipping creating archive file because backup did not complete successfully"
510532
fi
511533
}
512534

513535
generate_checksum() {
514-
if var_true "${ENABLE_CHECKSUM}" ;then
536+
if var_true "${ENABLE_CHECKSUM}" ; then
515537
if [ "${exit_code}" = "0" ] ; then
516538
case "${CHECKSUM,,}" in
517539
"md5" )
@@ -530,13 +552,16 @@ generate_checksum() {
530552
checksum_value=$(${checksum_command} "${target}" | awk ' { print $1}')
531553
print_debug "${checksum_extension^^}: ${checksum_value} - ${target}"
532554
else
533-
print_warn "Skipping Checksum creation because backup did not complete successfully"
555+
print_error "Skipping Checksum creation because backup did not complete successfully"
534556
fi
535557
fi
536558
}
537559

538560
move_dbbackup() {
539561
if [ "${exit_code}" = "0" ] ; then
562+
dbbackup_size="$(stat -c%s "${TEMP_LOCATION}"/"${target}")"
563+
dbbackup_date="$(date -r "${TEMP_LOCATION}"/"${target}" +'%s')"
564+
540565
case "${SIZE_VALUE,,}" in
541566
"b" | "bytes" )
542567
SIZE_VALUE=1
@@ -560,9 +585,7 @@ move_dbbackup() {
560585
"file" | "filesystem" )
561586
print_debug "Moving backup to filesystem"
562587
mkdir -p "${DB_DUMP_TARGET}"
563-
if var_true "${ENABLE_CHECKSUM}" ;then
564-
mv "${TEMP_LOCATION}"/*."${checksum_extension}" "${DB_DUMP_TARGET}"/
565-
fi
588+
mv "${TEMP_LOCATION}"/*."${checksum_extension}" "${DB_DUMP_TARGET}"/
566589
mv "${TEMP_LOCATION}"/"${target}" "${DB_DUMP_TARGET}"/"${target}"
567590
;;
568591
"s3" | "minio" )
@@ -581,17 +604,17 @@ move_dbbackup() {
581604

582605
[[ ( -n "${S3_HOST}" ) ]] && PARAM_AWS_ENDPOINT_URL=" --endpoint-url ${S3_PROTOCOL}://${S3_HOST}"
583606

584-
aws ${PARAM_AWS_ENDPOINT_URL} s3 cp ${TEMP_LOCATION}/${target} s3://${S3_BUCKET}/${S3_PATH}/${target} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
585-
unset s3_ssl
586-
unset s3_ca_cert
587-
if var_true "${ENABLE_CHECKSUM}" ;then
588-
rm -rf "${TEMP_LOCATION}"/*."${checksum_extension}"
607+
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 cp ${TEMP_LOCATION}/${target} s3://${S3_BUCKET}/${S3_PATH}/${target} ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
608+
if var_true "${ENABLE_CHECKSUM}" ; then
609+
silent aws ${PARAM_AWS_ENDPOINT_URL} s3 cp ${TEMP_LOCATION}/*.${checksum_extension} s3://${S3_BUCKET}/${S3_PATH}/ ${s3_ssl} ${s3_ca_cert} ${S3_EXTRA_OPTS}
589610
fi
611+
612+
rm -rf "${TEMP_LOCATION}"/*."${checksum_extension}"
590613
rm -rf "${TEMP_LOCATION}"/"${target}"
591614
;;
592615
esac
593616
else
594-
print_warn "Skipping moving DB Backup to final location because backup did not complete successfully"
617+
print_error "Skipping moving DB Backup to final location because backup did not complete successfully"
595618
fi
596619

597620
rm -rf "${TEMP_LOCATION}"/*
@@ -611,10 +634,11 @@ post_dbbackup() {
611634

612635
if var_true "${CONTAINER_ENABLE_MONITORING}" ; then
613636
print_notice "Sending Backup Statistics to Zabbix"
614-
silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.size -o "$(stat -c%s "${DB_DUMP_TARGET}"/"${target}")"
615-
silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.datetime -o "$(date -r "${DB_DUMP_TARGET}"/"${target}" +'%s')"
637+
silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.size -o "${dbbackup_size}"
638+
silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.datetime -o "${dbbackup_date}"
616639
silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.status -o "${exit_code}"
617640
silent zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k dbbackup.backup_duration -o "$(echo $((dbbackup_finish_time-dbbackup_start_time)))"
641+
if [ "$?" != "0" ] ; then print_error "Error sending statistics, consider disabling with 'CONTAINER_ENABLE_MONITORING=FALSE'" ; fi
618642
fi
619643

620644
### Post Script Support
@@ -641,6 +665,8 @@ post_dbbackup() {
641665
fi
642666

643667
print_notice "DB Backup for '${1}' time taken: $(echo ${dbbackup_total_time} | awk '{printf "Hours: %d Minutes: %02d Seconds: %02d", $1/3600, ($1/60)%60, $1%60}')"
668+
unset s3_ssl
669+
unset s3_ca_cert
644670
}
645671

646672
sanity_test() {

install/etc/services.available/10-db-backup/run

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ source /assets/functions/00-container
44
source /assets/functions/10-db-backup
55
source /assets/defaults/10-db-backup
66
PROCESS_NAME="db-backup"
7-
CONTAINER_LOG_LEVEL=DEBUG
87

98
bootstrap_variables
109

install/usr/local/bin/restore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ EOF
6666
exit 0
6767
;;
6868
"-i" )
69+
echo "interactive mode"
6970
interactive_mode=true
7071
;;
7172
* )
@@ -640,7 +641,7 @@ EOF
640641
2 )
641642
while true; do
642643
read -p "$(echo -e ${clg}** ${cdgy}Enter Value \(${cwh}C${cdgy}\) \| \(${cwh}E${cdgy}\) : ${cwh}${coff}) " q_dbport_menu
643-
case "${q_dbport_menu,,}" in
644+
case "${q_dbname_menu,,}" in
644645
c* )
645646
counter=1
646647
q_dbport=" "

0 commit comments

Comments
 (0)