Selective delete

Michael Sims michaels at crye-leike.com
Mon Nov 29 10:27:43 EST 2004


Dudi Goldenberg wrote:
> Is there a way to delete all messages in a specific (or all?) IMAP
> folders older then a specified number of days?
>
> I have a customer that holds ~50-500K msgs per folder.... An scheduled
> cleanup sounds like a good idea here ;-)
>
> Running Cyrus v2.1.7 on Debian Sarge.

I'm sure this isn't the recommended way to do it, but you could delete the message
files then run reconstruct on the user's mailbox (after making a backup, of course).
cd to the user's spool directory and run this:

# find -type f -name '[0-9]*.' -mtime +365

That should give you a list of which messages are older than a year (adjust to
desired value).  If it looks right then this should do the trick:

# find -type f -name '[0-9]*.' -mtime +365 -print0 | xargs -0 rm

Now run reconstuct on the user's mailbox and then rebuild the quota files and you
should be set.

Maybe someone else can suggest a way to do this through IMAP so you don't have to
get behind Cyrus's interface...

HTH

---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html




More information about the Info-cyrus mailing list