[Dovecot] (somewhat ot?) purging old maildir messages
I'm using Dovecot (+postfix) to host some personal imap accounts on a private server (Maildir format). I've got one account that receives mostly automated mails, and I want to be able to purge messages beyond a given date (say 30 days).
I know that since maildir uses flat files, I can literally just delete messages doing something similar to the following with bash:
for i in $(find /var/spool/vmail/host1/user/cur/ -mtime +30); do rm $i done
I dislike this approach for a few reasons. First, and most plainly, it seems crude. When running complex server software, its rarely a good idea in the field of systems administration to be bluntly deleting files out from under the running applications. It feels wrong. How does this affect dovecot's monitoring of the files and indexing? What if the files happen to be open in an email client? Etc.
Emotions aside, I also very much dislike running an automated 'rm' that has the power to wipe out a lot of my email if something goes pearshaped with the script.
I can think of several possible solutions that don't require subversive operations on the maildirs, but I've never used them and therefore don't know if they're actually feasible:
- Use a tool designed to manipulate maildirs. Something akin to postfix's postqueue and postsuper tools come to mind, but I don't know if such an app exists.
- Use a setting within dovecot that expires old maildir data. As I understand it this will be available in 1.1 (yay!); unfortunately that's not an option for me until 1.1 is available as stable in my server os.
- Use a scriptable mua that has the capability to check mail under said account and automatically delete based on age. I know very little of tools in this area, so again I don't know if such an application exists.
Any pointers you might have would be much appreciated.
Thanks, Matt
- Use a scriptable mua that has the capability to check mail under said account and automatically delete based on age. I know very little of tools in this area, so again I don't know if such an application exists.
I use this script with IMAP to make old mail as deleted and (optionally) expunge the folder:
http://johannes.sipsolutions.net/files/cleanspam.txt
johannes
Matt LaPlante, on 1/3/2008 12:02 AM, said the following:
- Use a setting within dovecot that expires old maildir data. As I understand it this will be available in 1.1 (yay!); unfortunately that's not an option for me until 1.1 is available as stable in my server os.
Does the expire plugin not do what you want?
http://wiki.dovecot.org/Plugins/Expire
--
Best regards,
Charles
Charles Marcus, on 1/3/2008 7:06 AM, said the following:
Matt LaPlante, on 1/3/2008 12:02 AM, said the following:
- Use a setting within dovecot that expires old maildir data. As I understand it this will be available in 1.1 (yay!); unfortunately that's not an option for me until 1.1 is available as stable in my server os.
Does the expire plugin not do what you want?
Never mind - I even saw the 1.1 comment but it went in one eye and out the other... gotta stop posting to mail lists before I've had my coffee...
--
Best regards,
Charles
On Thu, 3 Jan 2008 00:02:40 -0500, "Matt LaPlante" cyberdog3k@gmail.com wrote:
I know that since maildir uses flat files, I can literally just delete messages doing something similar to the following with bash:
for i in $(find /var/spool/vmail/host1/user/cur/ -mtime +30); do rm $i done
Hi!
If you want to purge emails that have been marked as deleted in Maildirs, use something like this:
find /var/spool/vmail/host1/user -name '*:2,*T*' -mtime +7 -exec rm -fv {} \;
This deletes all emails older than 7 days which are marked as deleted (flag T in Maildir format).
We are using this for quite a while and have seen no problems with dovecot imapd.
Greetings
Robert Sander Senior Manager Information Systems Epigenomics AG Kleine Praesidentenstr. 1 10178 Berlin, Germany phone:+49-30-24345-0 fax:+49-30-24345-555 http://www.epigenomics.com robert.sander@epigenomics.com
participants (4)
-
Charles Marcus
-
it-dovecot@ml.epigenomics.com
-
Johannes Berg
-
Matt LaPlante