[Dovecot] maildir maintenance?

Noel Butler noel.butler at ausics.net
Thu Nov 25 01:01:28 EET 2010

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:
> 1) Remove old messages marked as deleted.
> (I didn't really like the expunge/trash plugins the last time I looked
> at them.)
> 2) Rebuild the indexes to account of those changes.
> (So that the users aren't delayed by dovecot rebuilding them.)
> 3) Rebuild FTS indexes.
> (Again to avoid delay.)
> 4) 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";

-------------- next part --------------
A non-text attachment was scrubbed...
Name: face-smile.png
Type: image/png
Size: 873 bytes
Desc: not available
Url : http://dovecot.org/pipermail/dovecot/attachments/20101125/20d27a47/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20101125/20d27a47/attachment.bin 

More information about the dovecot mailing list