[Dovecot] Please HELP: how to delete all messages older than X days

Chris Young mrvjtod at gmail.com
Mon Aug 12 20:37:28 EEST 2013


I've got a nightly cron job that runs a bash script to delete old messages
from specific folders
doveadm expunge -A mailbox complete savedbefore 7d
doveadm expunge -A mailbox failed savedbefore 7d
doveadm expunge -A mailbox % savedbefore 60d

this deletes anything, in any mailbox, older than 60 days
and this deletes anything from /complete or /failed that is more than 7
days old.

I don't have people useing these mailboxes, they are all attached to
automation agents that don't do a good job of cleaning up after themselves.


On Mon, Aug 12, 2013 at 10:27 AM, Timo Sirainen <tss at iki.fi> wrote:

> On 8.8.2013, at 13.00, Răzvan Sandu <razvan.sandu at mobexpert.ro> wrote:
>
> > Pe 7 Aug 2013 11:35, Timo Sirainen a scris:
> >
> >>> Thank you, but doveadm expunge will ask for the mailbox name:
> >>>
> >>> [root at mail1 ~]# doveadm expunge -u john.doe at example.com ON
> >>> 2013-08-07 doveadm(root): Fatal: expunge: To avoid accidents,
> >>> search query must contain MAILBOX in all search branches
> >>
> >> Add: mailbox '*'
> >
> > Thank you, it works!
> >
> > May I use the same wildcard syntax ('*') when configuring the expire
> > plugin?  Something like:
> >
> > mail_plugins = $mail_plugins expire
> >
> > plugin {
> >  expire = *
> > }
>
> It should work, but I'm not sure if it's actually all that helpful. Might
> be more work to keep updating the expire database than to simply go through
> all users.
>
>


More information about the dovecot mailing list