I needed to migrate my mail server to a new machine. I created a new server and now it was time to move the user data. The method I'm going to use will disrupt mail services. Here we go.
Before any data can be moved we have to stop the mail services. So type the following.
> /etc/init.d/postfix stop
> /etc/init.d/cyrus-imapd stop
On the new server we need to make sure the same services are stopped. So type
> /etc/init.d/postfix stop
> /etc/init.d/cyrus-imapd stop
Now for the fun part. Go ahead and log in to the new mail server. Choose a temp directory for the mail store to be copied to. Lets use our friend scp to get the data.
> scp -rp root@host.domain.com:/var/lib/imap ./imap.lib
> scp -rp root@host.domain.com:/var/spool/imap ./imap.spool
> chown -R cyrus:mail imap.lib
> chown -R cyrus:mail imap.spool
> mv /var/spool/imap /var/spool/imap.old
> mv /var/lib/imap /var/lib/imap.old
> mv imap.lib /var/lib/imap
> mv imap.spool /var/spool/imap
The first thing we want to do is start up the services on the new server.
> /etc/init.d/cyrus-imap start
> /etc/init.d/postfix start
Login and check your mail using a mail client. If everything looks good then we need to remove the old imap directories.
> rm -Rf /var/lib/imap.old
> rm -Rf /var/spool/imap.old
I would consider this to be a brute force method. Mail service does get disrupted. In my case it was not a big deal.