[Dovecot] Compressing existing maildirs

Timo Sirainen tss at iki.fi
Thu Dec 29 15:48:05 EET 2011


On 29.12.2011, at 15.36, Jan-Frode Myklebust wrote:

> On Thu, Dec 29, 2011 at 02:55:40PM +0200, Timo Sirainen wrote:
>>> 
>>> I.e. find all maildir-files:
>>> 
>>> 	- with size in the name ("*,S=*")
>>> 	- modified before I enabled zlib plugin
>> 
>> As long as it doesn't find any already compressed mails..
> 
> Can't I trust that no mails with timestamp before I enabled compression
> are uncompressed? Or will dovecot compress old messages keeping old
> timestamp when copying messages between folders, or something like that?

It's possible that a user saves a mail with an old IMAP INTERNALDATE (=file's mtime), which is already compressed. You could use ctime, but that could skip mails whose flags have been changed since compression.

> I want to avoid reading every file to check if it's compressed
> already, as that will add ages to an already slow process..

You could use mtime, and just before compressing the mail check if it's already compressed. That won't add much overhead.

>>> 	- compress them 
>>> 	- add the Z suffix
>> 
>> Make sure there's also :2, suffix already. If someone hasn't logged in for a while there are such files in new/ directory.
> 
> So, 
> 	find /var/vmail -type f -name "*,S=*:2*" -mtime +6 -exec gzip -S Z -6 '{}' +
> 
> 
> Right ? I don't care too much if I miss on a few percent of the files..

Yes.


More information about the dovecot mailing list