maildir backup rotation is inconsitent when daily is greater than 7 or monthly greater than 4
Hi,
we ran into an issue where the rotation for backups is inconsitent. Perhaps though it may be differing expectations of the behaviour of the rotation.
We were using daily = 14 to keep two weeks of daily backups, followed by a series of weekly and monthly backups. We discovered that the dates of the weekly backups are inconsistent: for example, on the 18 of june the weeklies were the 3,2,1 of june and the 30 of april.
After tracing through the issue, what I believe to be happening is in this rotation code in the maildir handler. If keepdaily is 14, the max is 15. If daily.15 exists and there's not weekly.1 (eg. the weekly backup has been rotated), daily.15 is rotated in weekly.1. My normal expectation is that the weekly is checking pointed each week (7 days) instead of rotating a period that's two weeks old as if it were the last week.
The same logic is applied to the weekly to monthly roation, where if more than 4 weeks of weeklies are kept: the month.1 will be incorrectly offset.
max=\$((keepdaily+1))
if [ \( \$keepweekly -gt 0 -a -d $backuproot/daily.\$max \) -a ! -d $backuproot/weekly.1 ]; then
echo "Debug: daily.\$max --> weekly.1"
mv $backuproot/daily.\$max $backuproot/weekly.1
date +%c%n%s > $backuproot/weekly.1/rotated
fi
max=\$((keepweekly+1))
if [ \( \$keepmonthly -gt 0 -a -d $backuproot/weekly.\$max \) -a ! -d $backuproot/monthly.1 ]; then
echo "Debug: weekly.\$max --> monthly.1"
mv $backuproot/weekly.\$max $backuproot/monthly.1
date +%c%n%s > $backuproot/monthly.1/rotated
fi