convert from maildir to Cyrus DB
ken at oceana.com
Fri Feb 13 13:19:25 EST 2004
Craig Ringer wrote:
> On Fri, 2004-02-13 at 21:59, Andrew J Caird wrote:
>> One keyword that should find at least one message in the thread to get
>>you started is "mailutil".
> While I agree with the above suggestion (read the archives, consider
> using mailutil), I thought it'd be interesting to see if direct import
> was possible. Cyrus uses a custom mailbox format (one file per message
> like maildir, but otherwise unrelated to anything else AFAIK), so you
> can't just copy over mailboxes directly. I thought I'd see how hard it
> was to do so, though I question the utility and sensibility of doing so
> for anything but testing.
> It appears to be possible to import maildirs by renaming all messages to
> the cyrus-style 'n.' format, moving the directory into the desired
> location and fixing it's permissions. `reconstruct -r -f` didn't seem to
> want to find the mailbox, but using cyradm to 'cm' the path then
> reconstructing the mailbox seemed to work.
> To do the renaming, this works:
> #!/usr/bin/env python
> import os,sys
> msglist = os.listdir(sys.argv)
> for (mdid, uid) in map( lambda x,y:(x,y), msglist, range(1,
> len(msglist)+1 )):
> print "%s -> %s." % (mdid, uid)
> os.rename( mdid, "%s." % uid )
> then just:
> root# mv $maildir $cyrus_partition/$target_mailbox
> root# chown -R cyrus.mail $cyrus_partition/$target_mailbox
> cyrus$ [ using cyradm, 'add' the mailbox ]
> cyrus$ reconstruct -r -f $parent_of_target_mailbox
> I don't know if it's correct, it's definitely ugly, and it's probably a
> really bad idea to do. It did, however, appear to work.
> So - a question to those who know about the innards of the Cyrus mailbox
> handling: is it reasonable to import maildirs directly as a migration
Its probably reasonable, but you have to make sure that no messages are
delivered to this new mailbox before you're done reconstructing.
> Can significant problems be expected? Is it likely to be much
> faster to copy directly rather than use IMAP?
If the messages are already on the server then its probably faster to
just rename them.
> What about read status
> (the ,2BLAH suffix in maildir)?
Can't help you there. If you want flags preserved, then use IMAP.
> Oh, and allow me to repeat: if you use the method I've described above,
> without confirmation that it's safe, you're insane.
> Of course, if you can import maildir you can import mbox pretty easily,
How so? You have to split mbox the file into individual messages.
Kenneth Murchison Oceana Matrix Ltd.
Software Engineer 21 Princeton Place
716-662-8973 x26 Orchard Park, NY 14127
--PGP Public Key-- http://www.oceana.com/~ken/ksm.pgp
Home Page: http://asg.web.cmu.edu/cyrus
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html
More information about the Info-cyrus