On Tue, 2010-11-23 at 20:55 -0600, Brian Kroth wrote:
I recently wrote the attached script (could probably be improved) meant in theory to be run as a nightly cron job to do the follow:
- Remove old messages marked as deleted. (I didn't really like the expunge/trash plugins the last time I looked at them.)
- Rebuild the indexes to account of those changes. (So that the users aren't delayed by dovecot rebuilding them.)
- Rebuild FTS indexes. (Again to avoid delay.)
- Rebuild the maildirsize file. (It seems to become slightly inaccurate over time.)
To the devs, I'm wondering if this seems sane?
To other users of dovecot, I'm wondering what, if any sort of maintenance operations you tend to do in your setups?
Cleanup spam and trash folders is really all needs doing... I wrote this years ago and its never let us down, it could be written entirely in perl without system calls, but that requires a lot more code, I like keeping it simple, as it leaves little to go wrong, and I believe that if it aint borked, don't bork it, kinda thing :)
system("/usr/bin/find /var/vmail/*/*/*/*/*/Maildir/.Trash/ -name \"*,ST \" -mtime +7 -print | /usr/bin/perl -nle 'unlink;'"); system("/usr/bin/find /var/vmail/*/*/*/*/*/Maildir/.Junk/ -name \"*,S\" -mtime +30 -print | /usr/bin/perl -nle 'unlink;'");
@olddirs = /usr/bin/find /var/vmail/*/*/*/*/*/Maildir/.Trash.* -type d -mtime +7
;
if ((!@olddirs) or (@olddirs =~ "No such" )) {
print "nothing to do\n";
} else {
use File::Path qw(remove_tree);
foreach $odirdel (@olddirs){
chomp $odirdel;
print "Found: $odirdel \n";
remove_tree($odirdel);
}
}