Mail Migration

Discussion in 'General' started by ovis, Oct 12, 2005.

  1. ovis

    ovis ISPConfig Developer ISPConfig Developer


    My existing mail server has a cyrus imap service where 10+ people
    can read their webmail. My question to this forum is:

    If i wand to utilize ISPconfig, how can i seed the system with mail of my current mail server ?

    I did some research and came to this blog:

    Does any one here can recomment a sane strategy for usage with ISPconfig.

    Thanks in advance

  2. falko

    falko Super Moderator ISPConfig Developer

    ISPConfig is meant for "virgin" systems, so you might have a few problems with your migration.
    If Cyrus supports Maildir, then you can continue using it, otherwise I'd recommend Courier-IMAP.
    For the migration I think it would be the best to create new users in ISPConfig for your mailbox users, then copy over the existing emails to the new mailboxes and then delete the old users manually.
    But of course this is untested, so if it's a production system then do this at your own risk!
  3. ovis

    ovis ISPConfig Developer ISPConfig Developer

    Oke let me restate my question.

    On the server where the ISPconfig tool is intended, now runs a hacked up system of my own making. To end this unmaintainable situation i have to rm -fr / and start with a virgin system. But offcource not before i had made a backup of : Webs DataBases and Mail.

    The last one is the problem.

    My question in the first place was how to backup or otherwise store the Cyrus Imap accounts on the old server and migrate them to the virgin ISPconfig server witch uses Courier Imap.

    I understand that i have to define clients, webs and email users on the new system, but i havent got the slightes cleu about seeding my users with their original mail content and folders as they where used to in the old situation.

    I really wonder how many of the people using the ISPconfig tool must have a previous situation with content in the form of web db and email and managed to migrate that to the new situation.

    So what is the trick so i can get the mail + structure out of my old system into my new.


  4. falko

    falko Super Moderator ISPConfig Developer

    What's the structure of your mailboxes now? If each user has a Maildir with the directories cur, new and tmp in it, then you can try to simply copy them over to the new account.
  5. ovis

    ovis ISPConfig Developer ISPConfig Developer

    Mhh that the problem, I use qmail, it gets processed, and with a delivery agent, it ends up in e.g. /var/spool/imap/user/john/100.

    Now mail is accessable by imap.

    The only Maildirs used is by Qmail but only for a brief period when mail is being processed by the server to the Cyrus Imap system.

    So one way to migrate mail from this situation would be a solution like:

    I get the mail out of the old system and transfer it in the new. And that exactly where i lack the knowlege how where and so on. So before i even atempt, i consulted this support area.

    In short how can i go from:




    And than there's the issue of folders made by the users.
    Its the stuff where headackes are made off

    Thanks again for the help sofar

  6. falko

    falko Super Moderator ISPConfig Developer

    Is /var/spool/imap/user/john/100 a directory where all emails are stored in single files, or is /var/spool/imap/user/john/100 a file that contains all emails of a user? I need more information about this to understand the current structure of the mailboxes.
  7. SkIRmiS

    SkIRmiS New Member

    Read about: mb2md: convert mailbox to Maildir

    Perl tool to do that:

    Good luck!

    P.S don't forget to do backup before experiment!
  8. ovis

    ovis ISPConfig Developer ISPConfig Developer

    /var/spool/imap/user/john/ ---------------- Is the inbox
    /var/spool/imap/user/john/100. ----------- Is one email
    /var/spool/imap/user/john/101. ----------- Is another email
    /var/spool/imap/user/john/Trash ---------- Is a folder
    /var/spool/imap/user/john/Trash/64. ----- Is one email there
    /var/spool/imap/user/mike/45. ------------- Other user only one email

    And so on, the mails have numbers and there is also a database thats holding
    information about if a mail is new etc. This is a general Cyrus Imap structure.

    And that let me to believe that an external program has to transfer the mail from the still living server too a temporaly one. Then set up ISPConfig then retransfer the mail again.

    I hoped people here had similar experieces, but apperently i am the only one that has used Cyrus :)
  9. ovis

    ovis ISPConfig Developer ISPConfig Developer

    Oke in my case i need a imap to imap kinda tool. There are a lot of them and i investigate them one by one. Today i ran an experiment with mozilla email tool.

    I subscribed to both my original account and my ISPconfig test server.

    I was not be able to move folders so i have to move email per folder and per user
    wich is not a preferable situation.

    So if there is any one that has experience to get mail out of an IMAP system into the new ISPconfig system, creating folders on the fly ill be glad to hear

    Gr ovis
  10. falko

    falko Super Moderator ISPConfig Developer

    Courier uses the following structure:
    /var/www/webxx/user/webxx_<username>/Maildir/cur <-- folder that holds emails in single files
    /var/www/webxx/user/webxx_<username>/Maildir/new <-- folder that holds emails in single files
    /var/www/webxx/user/webxx_<username>/Maildir/tmp <-- folder that holds emails in single files

    Looks like this is not compatible with Cyrus-Imap's structure...
  11. ovis

    ovis ISPConfig Developer ISPConfig Developer

    Mail Migration ( Solved )

    Today after tryed 4 others I experimented with IMAP Sync, the perfect strategy for migrating mail to the new server.

    I hope this treatd helps others with similar problems

    gr ovis
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    Hi Ovis,

    thank you for the link, never heard of imapsync before. Maybe someone likes to write a small howto on mailmigration. I'am shure it will help many admins when switching to ISPConfig.

  13. ovis

    ovis ISPConfig Developer ISPConfig Developer

    Thats no problem


    The problem is that different Imap systems has different ways to store the email to disk. This makes the exanges from mail from one system to another inpossible.

    So here is the solution. A program logs in to the server and transfers it to another.
    Now it doent matter what physical system each IMAP Sysem uses.

    Install some non defauld Perl modules:


    perl -MCPAN -e shell

    install Mail::IMAPClient
    install Term::ReadKey


    And now ImapSync :

    tar zxvpf imapsync-1.139.tgz
    cd imapsync-1.139
    make install


    In the case of migration of the mail server on the same server:

    First make backups of mail webs and databases

    A Make a temporaly imap server: [email protected]
    Create Users there

    Migrate the mail

    Per user

    imapsync --host1 --user1 john --password1 secret \
    --host2 --user2 john --password2 secret

    Than do your perfect XXX setup, install ISPConfig make the sites users webs database etc

    And remigrate:

    imapsync --host1 --user1 john --password1 secret \
    --host2 --user2 web1_john --password2 secret

    Offcourse if your mail server is an other one you can use only the last example.

    The only downside to this strategy is, that its on a per user bases, that means you can only migrate one user after an other. This becomes a nightmare when migrating 100+ users. :mad:

    The upside is that the program creates the folder structure made by the user and migrate mail acordingly.

    Please feel free to use any of this information in this thread to use in a hint or howto.

    gr ovis

    PS if i have more info ill post it here.

Share This Page