0

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.

James Green
  • 895
  • 1
  • 9
  • 23
  • 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 Answers1

1

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.

Phil P
  • 3,080
  • 1
  • 16
  • 19