From fb0a7afb77e9c578c93544b1ca677697573bc696 Mon Sep 17 00:00:00 2001 From: ShortChanged13 Date: Thu, 7 Feb 2019 19:18:00 -0500 Subject: [PATCH] Added debug logging at the start of the backup and deletion loops. Added '$' to the end of the grep statements to enhance safety Removed extra blank line --- acts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/acts b/acts index 38899a8..8b674b9 100755 --- a/acts +++ b/acts @@ -144,11 +144,12 @@ fi # PART 3: Backup backuprc=0 # Notice any failed backups for dir in $backuptargets; do + log_debug "message=\"Starting backup of $dir\"" archive_starttime=$(date +%s) nicedirname=$(echo "$dir" | tr -d '/') # Determine the archive type to create - if echo "$archives" | grep -E -q "^$hostname-yearly-$year-.+-$nicedirname"; then - if echo "$archives" | grep -E -q "^$hostname-monthly-$year-$month-.+-$nicedirname"; then + if echo "$archives" | grep -E -q "^$hostname-yearly-$year-.+-$nicedirname$"; then + if echo "$archives" | grep -E -q "^$hostname-monthly-$year-$month-.+-$nicedirname$"; then # There's a yearly and monthly backup already archivetype="daily" else @@ -179,13 +180,13 @@ if [ "$backuprc" != "0" ]; then die "acts-tarsnap-error One of the backups failed -- not deleting old backups" fi - for dir in $backuptargets; do + log_debug "message=\"Checking $dir for old backups to delete\"" nicedirname=$(echo "$dir" | tr -d '/') # We don't delete any yearly backups # We keep 12 monthly backups - monthlybackups=$(echo "$archives" | grep "$hostname-monthly-.+-$nicedirname" | sort -rn) + monthlybackups=$(echo "$archives" | grep "$hostname-monthly-.+-$nicedirname$" | sort -rn) if [ "$(echo "$monthlybackups" | wc -l)" -gt 12 ]; then log_debug 'message="More than 12 monthly backups, deleting the oldest"' echo "$monthlybackups" | tail -n +13 | while read -r archiveprefixtodel; do @@ -200,7 +201,7 @@ for dir in $backuptargets; do fi # We keep 31 daily backups - dailybackups=$(echo "$archives" | grep "$hostname-daily-.+-$nicedirname" | sort -rn) + dailybackups=$(echo "$archives" | grep "$hostname-daily-.+-$nicedirname$" | sort -rn) if [ "$(echo "$dailybackups" | wc -l)" -gt 31 ]; then log_debug "message=\"More than 30 daily backups, deleting the oldest\"" echo "$dailybackups" | tail -n +32 | while read -r archiveprefixtodel; do