From 9b9a564447cc6bf1aa99b65e57c3ecafefe9aca4 Mon Sep 17 00:00:00 2001 From: Robert Bruce Park Date: Fri, 15 Nov 2013 10:35:04 -0800 Subject: [PATCH] More robust date handling. Previously the date handling expiry logic had a bug where if you had backups that were a year apart to the day, it wouldn't notice the difference in year and only notice that the month was the same, and expire the older one (eg, if you had a backup on 2012-04-01 and another on 2013-04-01, it'd delete the one from 2012. This commit makes it compare the full date string instead of just the month, so that it more robustly keeps older backups. --- rsync_tmbackup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rsync_tmbackup.sh b/rsync_tmbackup.sh index 1bad059..10ec4f7 100644 --- a/rsync_tmbackup.sh +++ b/rsync_tmbackup.sh @@ -190,11 +190,11 @@ while [ "1" ]; do elif [ $stamp -ge $KEEP_DAILIES_DATE ]; then # Delete all but the most recent of each day. - [ ${date:8:2} -eq ${prev:8:2} ] && fn_expire_backup "$fname" + [ "${date:0:10}" == "${prev:0:10}" ] && fn_expire_backup "$fname" else # Delete all but the most recent of each month. - [ ${date:5:2} -eq ${prev:5:2} ] && fn_expire_backup "$fname" + [ "${date:0:7}" == "${prev:0:7}" ] && fn_expire_backup "$fname" fi prev=$date