Move / merge Dovcot

Discussion in 'HOWTO-Related Questions' started by Entangled, Mar 6, 2019.

  1. Entangled

    Entangled Member

    Hello,

    Does anybody have any tricks to move and merge dovecot accounts?

    When the old mail server had issues starting on Friday, I brought up a new postfix / dovecot server in another location and started using it. Now that the old mail server is back online, I need to get the emails from the old server into the new server.

    Any ideas on how to do this without the need of the email account passwords because they are encrypted within dbispconfg?

    Thanks in advance,

    Craig
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Just copy the whole folders in /var/vmail/.... over to the other server. I assume you are using ISPconfig 3 which means that dovecot uses maildir format and in that format, each mail is in a separate file, so they won't collide. Dovecot will complain about broken indexes in the log, but that's uncritical, they will get repaired automatically. test this with one mailbox, if it works, copy the other ones over too.
     
  3. Entangled

    Entangled Member

    Thanks Till, but, I rsynced one mailbox last night, got into Roundcube, and only the new mail was there.

    I installed and ran imapsync ... this worked, but, it was rather slow, and I think it needs to used the mailbox password, which I did ... have not tried without the password, but, I think passwords are needed. I think the same is true for doveadm, which I have not attempted using yet.
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Did you check the copied files were in the correct directory with correct owner and permissions? This copying of e-mail files should just work.
     
    till likes this.
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Copying of files definitely works, used it many times in the past to merge and migrate servers. Regarding rsync, using rsync works as well for this job, just ensure that you don't tell rsync to delete files on the target system which are not on the sourec as this would delete all old emails.
     
  6. Entangled

    Entangled Member

    I take that back ... hmmm ...

    Got into RoundCube on new server for another Mailbox: 25 mails

    Then did:

    1) last night, I rsync-ed to /var/vmail2
    2) mv /var/vmail/mailbox/Maildir /var/vmail/mailbox/Maildir.NEW
    3) cp -Rp /var/vmail2/mailbox/Maildir / var/vmail/mailbox/.
    4) service dovecot stop
    5) service dovecot start

    Got into Roundcube ... there be the mail from the old server ... some 2500+.

    Know any tricks to get User settings from old Roundcube to new?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    RoundCube user/account settings are in the RoundCube database, but it's probably not easy to merge them.
     
  8. Entangled

    Entangled Member

    Don't need to merge the Roundcube User settings, need to copy them from old to new.
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Then you should be able to export the database on the old system and import it on the new one, at least when the RoundCube versions are the same, if not, then you might need to upgrade the database structure.
     
  10. Isterklister

    Isterklister New Member

    How about merge subfolders in Maildir, example Maildir/.Test? If I create them first and get in for example Thunderbird it is now problem but when I have many subfolders it is not practiacal.
     
  11. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    If by merge you mean combine two folders into one, that should work. Move e-mail files from one directory to the other. Dovecot notices this sooner or later and adjusts indexes and stuff accordingly.
    I can not make sense of that sentence.
    But moving emails in Thunderbird from one folder to another also works. I have done it several times.
     
  12. Isterklister

    Isterklister New Member

    I can try to explain better.
    Here are the folder structure of the old Maildir for user User1:
    ...User1/Maildir/cur
    dovecot.index
    ...
    dovecot.uidvalidity
    ...User1/Maildir/.Drafts
    ...User1/Maildir/.Golf
    ...User1/Maildir/.Skottland

    ...User1/Maildir/new
    ...User1/Maildir/.Sent
    ...User1/Maildir/tmp
    ...User1/Maildir/.Trach

    It is the two examples in bold that are the problem. In each of theese folders there are new dovecot.index and other dovecot files.
    How can I merge theese folders to new server?
     
  13. Steini86

    Steini86 Active Member

    For moving files from one server to another dovecot use dsync: https://wiki2.dovecot.org/Migration/Dsync
    For moving mails on one server use doveadm move: https://wiki.dovecot.org/Tools/Doveadm/Move
    This way all index files and permissions are correct.

    Alternatively: Copy just the mail files, delete the dovecot files and indexes and let them regenerate. This has some side effects like the clients are re-downloading all mails.
    This can be done with doveadm force-resync: https://wiki2.dovecot.org/Tools/Doveadm/ForceResync
    But then it would be better to have the folder somewhere else and use dovecot to import them via doveadm import: https://wiki2.dovecot.org/Tools/Doveadm/Import
    So basically import the two folders you want to merge into a single one in the new mailbox.
     
    Last edited: Jan 21, 2020
    till likes this.

Share This Page