How can I migrate Dovecot from one server to another?

I have a Dovecot installation on a Fedora 12 "server" at home and I want to move all my mailboxes onto a virtual CentOS 5 server.

How can I do this? Which files to I have to copy? Is it even enough to copy files or do I have to be prepared for some configuration and/or file format issues?


Assuming you're talking about IMAP mailboxes, I would go a different way. Setup the second (virtual) server to your liking, test it and make sure everthing is working as expected. Then use a tool like imapsync to sync/copy over your mailboxes. I have already done this sucessfully a couple of times. You might want to stop your MTA (sendmail, postfix, ...) while you're migrating the mailboxes.

Also have a look at migration page at the dovecot wiki.


You should copy the configuration file /etc/dovecot.conf and the mail files. Depending on your installation, mail files can be in /var/spool/mail, but also in /home directories. Of course you have to copy also the files (or the tables, or piece of files) needed for login and password validation.

Dovecot has many options for mail storage and user validation, so the file you have to copy are different depending on your configuration.


Dovecot 2.1.8 and higher includes a tool for it called "dsync". For more information:

$ doveadm help sync

I don't know if you'll run into permission issues in moving those items like config files and spool files (probably not), but you'd need to make sure that all the items are the same between your machine and the centos machine (again, both are Red Hat based, so you probably wouldn't have trouble).

If you're using a virtual machine based on VMWare, I'd propose using the VMWare converter to virtualize your physical machine. I don't know if it's feasible for your purposes, but I've converted more than one working server into a virtual machine just so I wouldn't have to deal with migration headaches. I then just dealt with changing the IP address, machine name, things like that rather than the sometimes more hairy issues involving migration of users in a database or mail spool. I figured the downtime in converting IP addresses and installing VMWare tweaks would be less than potential downtime from untangling spool/permission/lost files/etc. issues in moving from Machine A to Machine B.

Sometimes altering the machines network config has fewer gotcha's than playing with all the interactions of mail systems with their validations, authentications, and spool issues :-)


If you use a migrate feature with an IMAP connection, you lose the \Recent flag on any messages. Some clients (which I'm not sure of) appear to use this instead of \Seen to determine if the message is new. Unfortunately, RFC3501 prohibits setting the \Recent flag on any message ever, and once you've accessed the message in some way, the server unsets the flag.

If you choose a direct file copy solution, just make sure you copy the .imap directory with the files. (It is in whatever is set as the user's mail folder directory.) That folder contains the database that dovecot uses to keep track of the flags. If you don't stop mail delivery altogether on the source server, you'll need to handle locking to stop delivery to the user. Then copy the files, install a forward and unlock them.