4

In short: Does anyone know of a step-by-step guide to migrate maildir data from one dovecot to another?

In long: I try to migrate my mail server to a new machine.

I first tried to simply tar & rsync my single maildir directory but all subfolders were grayed out in thunderbird.

So I thought I do it again with doveadm sync but now I simply find no clear path how to do it with the dovecot manual, google or serverfault.

Is there really no easy step-by-step guide to do this available yet? Or is it just too easy and I don't get it? The manual does not contain enough explanation for a mailserver noob like me.

  1. doveadm sync/backup

    I started with doveadm backup -u [email protected] .... It tells me:

    doveadm(root): Error: User doesn't exist

    But doveadm user *@domain.tld returns exactly this user. Now I stumbled upon the point below, so I don't try to understand this problem for now.

  2. doveadm import

    As I already have the data tar & rsynced to my new machine I tried this next.

    I started the docker container without ports open so dovecot is running but none can connect to postfix or dovecot.

    I attached to the console of the container and tried doveadm import. Got permission denied issues. Tried with permissions set to 777. doveadm import finished without telling me about any problems but the dir of the user is still empty (just the standard folders no mails)

1
  • 1
    Requests for guides and documentation are off-topic here. Instead, describe exactly what you did and how that failed in order to help you. In general, I would recommend to use a tool to migrate IMAP mails from the old server to the new via IMAP and not by normal file system operations (this keeps your metadata intact). Have a look at imapsync for this, it's not free but by far the best tool available for this job.
    – Sven
    Mar 29, 2018 at 15:59

4 Answers 4

4

The reason for me not being successful with finding a good dovecot<->dovecot copy guide was that there is an easy and more generic imap<->imap way of doing it. (For example ImapSync Thanks Sven for your comment to my question).

ImapSync: I did it this way.

  1. Download the code from github and build it
  2. use it

Necessary dependencies for the build

apt-get install makepasswd rcs perl-doc libio-tee-perl git libmail-imapclient-perl libdigest-md5-file-perl libterm-readkey-perl libfile-copy-recursive-perl build-essential make automake libunicode-string-perl libauthen-ntlm-perl libcrypt-ssleay-perl libdigest-hmac-perl libfile-copy-recursive-perl libio-compress-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-tee-perl libmodule-scandeps-perl libnet-ssleay-perl libpar-packer-perl libreadonly-perl libterm-readkey-perl libtest-pod-perl libtest-simple-perl libunicode-string-perl liburi-perl cpanminus

CPAN modules (CPAN = Comprehensive Perl Archive Network)

 cpanm JSON::WebToken Test::MockObject Unicode::String Data::Uniqid

Then get the imapsync code from github and build with make install

When done, using it is as easy as

imapsync \
    --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
    --host2 test2.lamiral.info --user2 test2 --password2 secret2

More details here

1
  • 1
    To know of all the necessary dependencies, I suggest you type sudo make install. Unfortunately, the install target is not going to install the dependencies automatically, but it's going to tell you what's missing and allow you to install it manually before finishing the installation. Feb 27, 2022 at 16:59
2

I've migrated from a Wheezy based postfix+courier+mysql to a Stretch based one (postfix+mysql+dovecot) with slightly updated config plus a few new options on a fresh install.

The key for my migration was that the users are all virtual (via mysql tables) and all mail was stored in /home/vmail/domain/user/[various maildirs]

New system has similar structure for maildirs, just under /var/vmail/domain/user instead of /home/vmail...

Only "trick" to it was copying the files and making sure correct ownership and other permissions were applied on the new location.

2
  • Did you also copy those dovecot index files? (Because I think they made dovecot send those \NONEXISTENT flags for my subfolders leading to thunderbird graying them out.)
    – andymel
    Apr 1, 2018 at 10:50
  • @andymel - copied the entire structure from /home/vmail/ to /var/vmail - everything from ....../vmail down was copied directly. In both cases all files/dirs were owned by vmail user and vmail group.
    – ivanivan
    Apr 1, 2018 at 12:56
1

you COULD use imapsync actually… but it failed me with some obscure error.

rsync is NOT a good idea… because dovecot/thunderbird/icedove does not rebuild index files/folder structure.

the solution is actually simple: use thunderbird/icedove your mail client!

  1. create same mail account on new server as on old server
  2. add old and new account inside thunderbird (you can use IP addresses if the domain is already pointing to the new server)
  3. drag and drop the old mails-folders from your old account to your new account wait… all mails get downloaded locally from your old account and then uploaded to your new account.

PS: Thanks for voting down on my last improvement post and removing "hooray". this platform sucks. i really think about a boycott.

1
  • The question is about moving the whole server (lots of email accounts), and not one individual account... You would need to setup each account in email client (+guess or fake their passwords) for your solution to work.
    – Marki555
    Nov 16, 2021 at 11:41
-1
hostnamectl 
   Static hostname: debian
         Icon name: computer-vm
    Virtualization: oracle
  Operating System: Debian GNU/Linux 9 (stretch)
            Kernel: Linux 4.9.0-6-amd64
      Architecture: x86-64

tried this today IMHO think also missing:

apt install libssl-dev

then complains:

Here is a cpanm command to install missing Perl modules:
cpanm "Crypt::OpenSSL::RSA Dist::CheckConflicts JSON::WebToken::Crypt::RSA Regexp::Common Sys::MemInfo"
Makefile:99: recipe for target 'testp' failed
make: *** [testp] Error 1

So I tried:

cpanm Crypt::OpenSSL::RSA Dist::CheckConflicts JSON::WebToken::Crypt::RSA Regexp::Common Sys::MemInfo

then "make install" worked:

imapsync -v
1.882

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .