Merging maildirs

Steffen Kaiser skdovecot at smail.inf.fh-brs.de
Fri Aug 28 07:54:02 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 27 Aug 2015, Petter Gunnerud wrote:

> How do I merge files from one maildir into another maildir?

> 5 days ago the internet connection at the office broke, and I decided to 
> power on the last copy of the server at my home and change public dns so 
> that users could access their new mails via webmail from this spare 
> server. (I didn't allow imap through firewall.)

> Now the network at the office is back. DNS is updated so that mails are 
> delivered to the office server again. But all the mails sent / received 
> during those 5 days is only at my house. How can I merge those into the 
> office server?I'd like to do this as a server administrator. I do not 
> want to have each user forward the mails to them self from the 
> temporarily webmail.

You have now:

two copies of old messages, 1 set with new ones and another one with newer 
ones. Both copies have a different set of messages, that habe been moved, 
copied, flagged, tagged, and expunged.

> I tried to just copy the mail files on my own account - like I did once when I used courier-imap, but that did not work with dovecot.

You say, you use Maildir.
If you copy the files from {new,cur} of the backup server into the 
corresponding directories of the production server (no dovecot* files!), 
the mtime of the {new,cur} directories of the production server should 
update und Dovecot is to detect the changes. It will then re-index the new 
messages.

However, you might run into issues, because message tagging or flagging is 
reflected in the filename following the ','. E.g:

1426783429.M295788P8020.mailsrv,S=5497,W=5593:2,Sa

'Sa' are tags and flags. The rest is the 'stem'.

I did "merging" in this way:

1) copy the backup files to the production server,
2) remove all files from this set, which are not located in cur/ or new/ 
directories,
3) check, which files in both sets have the same content, ignoring 
filename and mtime and such, those are removed from the backup set,
4) move all remaining files retaining the path into the production 
Maildir.

Step 3 is a bit tricky, because users may copy one message into another 
mailbox, thus making duplicates.

You can compare mailbox by mailbox or Maildir-wide. Both ways have pros 
and cons.

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEVAwUBVeATmnz1H7kL/d9rAQJz7wf+JlG0lNb9454aUuVFtnGLx+bs4122fZgI
j2o5YewEWUze+FJEdwJXRa+CD2OjdUrcnSJnAPdD2f3M6WMuVNiO1+3oG149TfNJ
TZu1KhyopsU49snFBMjhjU5/1w9GJTnfPd7rFKBa841lYwbQmw9sdnBnkkdcJWG0
oZGgfRwcsKpasVwiqwvjF62lwoWImRsFvsCDIdv81lGBBmRSULs4CwG0wl/qi94B
WCAznbDCB4v6dBD2bvsrX+62MHtv+V4d34beDZAEXEv697Ge4Cs1cCTC+gQjHcyH
e8sNMpEaHxgpOMjYM8DwDB6kNQen9gbG9cEaBl8rxRGTx3yjjaRSYA==
=MP88
-----END PGP SIGNATURE-----


More information about the dovecot mailing list