[Dovecot] Automatic Folder Expiry (plugin?)
Greetings,
I'm migrating an existing Courier IMAP installation to Dovecot (1.0rc19 right now) on a new server; there's one feature I'm not sure if Dovecot supports - but it might and I'm missing it, so I'll ask.
In Courier there's an option to expire a folder after a given time period; ostensibly it's to keep a Trash folder clean, but we use it to keep the Junk folder (where spam is delivered by Exim) clean.
How can I do this in Dovecot? Here's the chunk from Courier for those unfamiliar with it (just part of the verbiage):
##NAME: IMAP_EMPTYTRASH:0 # # The following setting is optional, and causes messages from the given # folder to be automatically deleted after the given number of days. # IMAP_EMPTYTRASH is a comma-separated list of folder:days. # # Important: the purging is controlled by CTIME, not MTIME ...
So in our case it's set like so:
IMAP_EMPTYTRASH=Junk:14
Thanks for any help/ideas - I'm not sure if we can live without this feature, the amount of spam is horrendous and users never clean out that folder.
-te
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
Troy Engel wrote:
Greetings,
I'm migrating an existing Courier IMAP installation to Dovecot (1.0rc19 right now) on a new server; there's one feature I'm not sure if Dovecot supports - but it might and I'm missing it, so I'll ask.
Checkout http://wiki.dovecot.org/Plugins. You can search the mailing list archives for details on how to implement it. Timo has documented it a few times on the list.
HTH, Channing
-- A: Yes.
Q: Are you sure?
A: Because it reverses the logical flow of conversation.
Q: Why is top posting annoying in email?
Channing wrote:
Checkout http://wiki.dovecot.org/Plugins. You can search the mailing list archives for details on how to implement it. Timo has documented it a few times on the list.
I'll assume you're talking about the Trash plugin, yes? I've seen this and understand it, but it is quota based -- we don't use quotas, and it doesn't do what I want anyways. Something similar but was based on date (days) rather than Quota, and didn't empty that mailbox just deleted the
XXX days messages.
thx, -te
PS: is there a searchable web archives link that I missed? The standard Mailman archives have no searching capability.
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
Checkout http://wiki.dovecot.org/Plugins. You can search the mailing list archives for details on how to implement it. Timo has documented it a few times on the list.
I'll assume you're talking about the Trash plugin, yes? I've seen this and understand it, but it is quota based -- we don't use quotas, and it doesn't do what I want anyways. Something similar but was based on date (days) rather than Quota, and didn't empty that mailbox just deleted the
XXX days messages.
Actually, the plugin you are looking for is named Expire, but it does not work with the current Dovecot version. You need the CVS head version, which I do not believe is recommended for use in production. The Trash plugin is completely separate.
The Expire plugin is currently only mentioned in the Wiki in a paragraph at the bottom of the Lazy Expunge plugin. For some documentation on its use, see: http://www.dovecot.org/list/dovecot/2006-June/013864.html http://www.dovecot.org/list/dovecot/2006-November/017408.html
Scott
Scott Alter wrote:
Actually, the plugin you are looking for is named Expire, but it does not work with the current Dovecot version. You need the CVS head version, which I do not believe is recommended for use in production. The Trash plugin is completely separate.
Aha! Thanks for those links and the info; even if I can't use it right now it's good to know it's in the works with HEAD. I'll probably use Mike T's trick for now and just keep an eye out on the newer releases...
Since I'm new to dovecot I'm not familiar with the release roadmap -- is this something slated for inclusion to a future RC for 1.0, or are we talking it's pushed out to 1.1 (sic) or whatnot? I'm guessing the latter...
thanks! -te
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
Troy Engel wrote:
Thanks for any help/ideas - I'm not sure if we can live without this feature, the amount of spam is horrendous and users never clean out that folder.
I personally use a shell script to achieve this:
find /var/virtualmail/ -regex
'.*/\.\(Trash\|Junk\)\(/.*\)?\/\(cur\|new\)/.*' -type f -mtime +30
-exec rm '{}' \;
MT
Mick T wrote:
I personally use a shell script to achieve this:
find /var/virtualmail/ -regex '.*/\.\(Trash\|Junk\)\(/.*\)?\/\(cur\|new\)/.*' -type f -mtime +30
-exec rm '{}' \;
Nice. :) What's your load like doing this compared to number of users? I'm using a Maildir-on-NFS setup here, so there's always that to account for as well... I'm guessing you run this at 5am or so daily?
What about the Dovecot indexes -- will they adjust/fix/repair automagically when the user logs in? Same with dovecot-uidlist, it's self-healing?
-te
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
Nice. :) What's your load like doing this compared to number of users? I'm using a Maildir-on-NFS setup here, so there's always that to account for as well... I'm guessing you run this at 5am or so daily? I have around 5000 mailboxes on local SCSI drives, but yeah I nice -20
Troy Engel wrote: the script, and run early in the morning. It doesn't take too long to run
What about the Dovecot indexes -- will they adjust/fix/repair automagically when the user logs in? Same with dovecot-uidlist, it's self-healing? I'm not the best person to answer this question, but its worked for me so far :)
MT
Mick T wrote:
I have around 5000 mailboxes on local SCSI drives, but yeah I nice -20
the script, and run early in the morning. It doesn't take too long to run
Cool, thanks. (sorry about the Mike T instead of Mick T in the other response, oops) I found that I get a nice speed boost by using a bit more bash-fu with find's target, since my mailboxes are NFS I want tailor to what I know we have. Since all mailboxes are /home/X/XXXX/ (e.g. /home/t/tengel/) I am going with:
find /home/*/*/ -regex '.*/Maildir/\.Junk/\(cur\|new\)/.*' -type f -ctime +14 -exec rm -f '{}' \;
I ran a quick test using some ls -l action instead of rm to get a speed test idea:
# time find /home/*/*/ -regex '.*/Maildir/\.Junk/\(cur\|new\)/.*' -type f -ctime +7 -exec ls -l '{}' \; > results.log
real 23m15.837s user 0m54.882s sys 1m22.567s
That'll do! Not the fastest, but it works. :) -te
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
On Feb 1, 2007, at 9:58 AM, Troy Engel wrote:
Mick T wrote:
I have around 5000 mailboxes on local SCSI drives, but yeah I nice
-20 the script, and run early in the morning. It doesn't take too
long to runCool, thanks. (sorry about the Mike T instead of Mick T in the
other response, oops) I found that I get a nice speed boost by
using a bit more bash-fu with find's target, since my mailboxes are
NFS I want tailor to what I know we have. Since all mailboxes are / home/X/XXXX/ (e.g. /home/t/tengel/) I am going with:find /home/*/*/ -regex '.*/Maildir/\.Junk/\(cur\|new\)/.*' -type f - ctime +14 -exec rm -f '{}' \;
You'll probably have better luck with:
find /home/?/????/.*/Maildir/.Junk -regex '\(cur\|new\)/.*' -type f - ctime +14 -print | xargs rm -f
This will not work well with spaces in the paths. Switch back to -
exec if so. You might also run into limitations with find with 5000
mailboxes. Then I'd switch to
for i in /home/?/????/.* do find $i/Maildir/.junk . . . done
You can also background the find then, and run 'em in parallel.
I ran a quick test using some ls -l action instead of rm to get a
speed test idea:# time find /home/*/*/ -regex '.*/Maildir/\.Junk/\(cur\|new\)/.*' - type f -ctime +7 -exec ls -l '{}' \; > results.log
real 23m15.837s user 0m54.882s sys 1m22.567s
That'll do! Not the fastest, but it works. :) -te
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
On Thu, Feb 01, 2007 at 10:24:55PM -0800, Sean Kamath wrote:
You'll probably have better luck with:
find /home/?/????/.*/Maildir/.Junk -regex '\(cur\|new\)/.*' -type f - ctime +14 -print | xargs rm -f
This will not work well with spaces in the paths. Switch back to - exec if so. You might also run into limitations with find with 5000
If using GNU find / xargs you can use the '-print0' find
option and the '-null' xargs option which should handle white-
space'd filename properly.
John
-- "I'm sorry but our engineers do not have phones." As stated by a Network Solutions Customer Service representative when asked to be put through to an engineer.
"My other computer is your windows box." Ralf Hildebrandt
Sean Kamath wrote:
find /home/?/????/.*/Maildir/.Junk -regex '\(cur\|new\)/.*' -type f -ctime +14 -print | xargs rm -f
Close! I actually reworked it and have a good working solution, and it turns out xargs is much faster than -exec. The final line I have is:
find /home/*/*/Maildir/.Junk/ -regex '.*/\(cur\|new\)/.*' -type f -ctime +14 -print0 | xargs -0 rm -f
...which brought me down to about 1m 12sec or so, but I'm sure there's a lot of caching here. Regardless it's still a very nice increase!
thanks, -te
-- Troy Engel | Systems Engineer Fluid, Inc | http://www.fluid.com
participants (6)
-
Channing
-
John R. Dennison
-
Mick T
-
Scott Alter
-
Sean Kamath
-
Troy Engel