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.
This commit is contained in:
Robert Bruce Park 2013-11-15 10:35:04 -08:00
parent ae7998025a
commit 9b9a564447

View file

@ -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