Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Following an outage, I've ended up with 2 mailboxes for each of my users, on separate machines. I've shut the interim machine down now, and put the mailboxes on the real server in /srv/scratch/$username/Maildir/..., and need to integrate the messages from them, ideally preserving read/seen state, into the users' canonical mailboxes, /srv/mail/$username/Maildir/.... I have no preference for whether this is as a sub-folder, or in their main inbox, however I am confident none of the temporary mailboxes contain sub-folders themselves. (If they do, more fool the users, who were explicitly told not to do this on the temporary accounts!)

Is there a good way to do this which minimises risk of loss of mail, and means their clients will automatically pick up the new folder/messages (whichever it needs to be) when they reconnect? Alternatively, what do I need to do to tell Dovecot about the new messages after dumping them into the Maildirs?

Both servers were built using Exim4 for delivery and Dovecot for IMAP.

share|improve this question
    
My best plan so far: for each user, create Maildir/.INBOX.tmp and move cur, new etc into it. Then append ".INBOX.tmp" to the end of Maildir/subscriptions. Am I nuts? –  James Green Feb 14 '11 at 20:38

1 Answer 1

up vote 1 down vote accepted

I'd script moving the files into place using almost the Maildir delivery specification, which involves using the tmp/ dir and then renaming into the new/ dir, but for this you'd rename into the cur/ or new/ dir, depending upon where the original file was.

Given that the filenames embed timestamps, you should have very few (zero) collisions, but paranoia is good. Write the file into tmp/; if this was a cur/ file, save away the state suffix outside the filename; whether moving to new/ or cur/ check both for existence of the same name in new/ or the same prefix in cur/; then rename as appropriate.

Be careful not to lose the suffix on the cur/-in-tmp/ through a memory crash; a logfile journal of all actions taken will help you reconstruct if something goes wrong.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.