Converting from mbox to maildir: Difference between revisions

From Edgar BV Wiki
Jump to navigation Jump to search
Created page with "converting from mbox to maildir for imap '''problem:''' mbox format doesn't allow subfolders in imap. mbox is a mailfile in /var/mail/ and maildir is 1 file per email in the..."
 
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 31: Line 31:


* change the way dovecot-pop3d picks up mail
* change the way dovecot-pop3d picks up mail
* Migration!
First, create a master user on the server you're going to migrate from:
/etc/dovecot.conf
<pre>
auth_master_user_separator=*auth default {  passdb passwd-file {    args = /etc/dovecot/passwd.masterusers    master = yes    pass = yes  }  passdb shadow {  }  userdb passwd {  }}
</pre>
Create the master user in the new file:
<pre>
htpasswd -b -c -s passwd.masterusers user password
</pre>
Test it (NB mind the '1' you do have to type this in!):
<pre>
# telnet localhost 143* OK Dovecot ready.1 login loginuser*masteruser masterpass1 OK Logged in.
</pre>
Also see:
http://wiki1.dovecot.org/Authentication/MasterUsers
http://wiki2.dovecot.org/Migration/Dsync


* convert the mbox mailboxes to maildir format:
* convert the mbox mailboxes to maildir format:


This converts mboxes to maildirs per user
This converts mboxes to maildirs per user
http://wiki.dovecot.org/Migration/MailFormat
<pre>
dsync -u red mirror mbox:~/mail:INBOX=/var/mail/red
</pre>
If you get dotlock time errors, make sure all the machines are running ntp.
It could be that the existing user allready has folders in their setup because they've been using squirrelmail or imap or sometihng. This will give errors during the conversion of the type:
<pre>
dsync(razor): Error: Can't rename mailbox INBOX to INBOX_13cabe1b5cfff750fa080000ba1da2b1: Renaming INBOX isn't supported.
dsync(razor): Error: Can't rename mailbox INBOX_e72e0e3ad3f4ff5019600000ba1da2b1 to INBOX: Target mailbox already exists
</pre>


http://batleth.sapienti-sat.org/projects/mb2md/
http://batleth.sapienti-sat.org/projects/mb2md/


http://wiki.dovecot.org/Migration/MailFormat
But Dovecot1 has its' own system, which Dovecot2 doesn't:
 
http://wiki.dovecot.org/Plugins/Convert  <- NB also see alternative formats underneath page
 
= step by step, user by user =
 
== On edgarmail: ==
 
copy users from ghost to edgarmail /etc/passwd /etc/passwd- /etc/shadow /etc/shadow- /etc/group /etc/group-
 
copy users into /etc/postfix/virtual on edgarmail
 
ensure domain is in /etc/postfix/virtual-domains on edgarmail
 
<pre>
postmap virtual
postfix reload
</pre>
 
make sure the username/mail and username/mail/.imap/ directories and files are all chown the user and chgrp the usergroup on ghost
 
== on edgarghost ==
Per user sync the mailboxen from old system to new (run from ghost):
<pre>
dsync -u username mirror mbox:~/mail:INBOX=/var/mail/username
</pre>
resolve errors
NB makkelijk is om /home/sites/site/userid/Maildir directory geheel te verwijderen voor de sync. Kans is hoog dat ze die namelijk nog nooit hebben gebruikt, BEHALVE als ze ooit hun mail via imap.edgarbv.com hebben opgehaald.
 
== In Outlook / mailclient: ==
Create new account with IMAP server / imap.edgarbv.com
 
test
 
make sure the sync is finished
 
log in to roundcube (http://imap.edgarbv.com)


But Dovecot has its' own system:
set up identity


http://wiki.dovecot.org/Plugins/Convert  <- NB also see alternative formats underneath page
send testmail to gmail / hotmail using roundcube and mail client
then start copying the folders over.

Latest revision as of 19:55, 18 January 2017

converting from mbox to maildir for imap

problem: mbox format doesn't allow subfolders in imap.

mbox is a mailfile in /var/mail/ and maildir is 1 file per email in the users homedir/Maildir


Steps:

  • replace popa3d with dovecot-pop3d

change protocols in dovecot

http://www.debiantutorials.com/installing-dovecot-imap-and-pop-daemon-with-mysql-backend/

  • Get postfix to deliver in maildir format

postconf -e "home_mailbox = Maildir/"

postconf -e "mailbox_command ="

http://wiki.debian.org/Postfix#Maildir

  • change the way procmail delivers mail

DEFAULT="$HOME/Maildir/"

MAILDIR="$HOME/Maildir/"

http://wiki.dovecot.org/procmail (with more options for faster delivery)

  • change the way dovecot-pop3d picks up mail
  • Migration!

First, create a master user on the server you're going to migrate from:

/etc/dovecot.conf

auth_master_user_separator=*auth default {  passdb passwd-file {    args = /etc/dovecot/passwd.masterusers    master = yes    pass = yes  }  passdb shadow {  }  userdb passwd {  }}

Create the master user in the new file:

htpasswd -b -c -s passwd.masterusers user password

Test it (NB mind the '1' you do have to type this in!):

# telnet localhost 143* OK Dovecot ready.1 login loginuser*masteruser masterpass1 OK Logged in.

Also see: http://wiki1.dovecot.org/Authentication/MasterUsers

http://wiki2.dovecot.org/Migration/Dsync

  • convert the mbox mailboxes to maildir format:

This converts mboxes to maildirs per user

http://wiki.dovecot.org/Migration/MailFormat

dsync -u red mirror mbox:~/mail:INBOX=/var/mail/red

If you get dotlock time errors, make sure all the machines are running ntp.

It could be that the existing user allready has folders in their setup because they've been using squirrelmail or imap or sometihng. This will give errors during the conversion of the type:

dsync(razor): Error: Can't rename mailbox INBOX to INBOX_13cabe1b5cfff750fa080000ba1da2b1: Renaming INBOX isn't supported.
dsync(razor): Error: Can't rename mailbox INBOX_e72e0e3ad3f4ff5019600000ba1da2b1 to INBOX: Target mailbox already exists

http://batleth.sapienti-sat.org/projects/mb2md/

But Dovecot1 has its' own system, which Dovecot2 doesn't:

http://wiki.dovecot.org/Plugins/Convert <- NB also see alternative formats underneath page

step by step, user by user

On edgarmail:

copy users from ghost to edgarmail /etc/passwd /etc/passwd- /etc/shadow /etc/shadow- /etc/group /etc/group-

copy users into /etc/postfix/virtual on edgarmail

ensure domain is in /etc/postfix/virtual-domains on edgarmail

postmap virtual
postfix reload

make sure the username/mail and username/mail/.imap/ directories and files are all chown the user and chgrp the usergroup on ghost

on edgarghost

Per user sync the mailboxen from old system to new (run from ghost):

dsync -u username mirror mbox:~/mail:INBOX=/var/mail/username

resolve errors NB makkelijk is om /home/sites/site/userid/Maildir directory geheel te verwijderen voor de sync. Kans is hoog dat ze die namelijk nog nooit hebben gebruikt, BEHALVE als ze ooit hun mail via imap.edgarbv.com hebben opgehaald.

In Outlook / mailclient:

Create new account with IMAP server / imap.edgarbv.com

test

make sure the sync is finished

log in to roundcube (http://imap.edgarbv.com)

set up identity

send testmail to gmail / hotmail using roundcube and mail client then start copying the folders over.