Status/History
Introduction
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.
Preparing the Current Server
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
The New Server
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
Moving the Data
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
Testing and Cleanup
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
Conclusion
I would consider this to be a brute force method. Mail service does get disrupted. In my case it was not a big deal.
Comments
Comments Closed.
rcamp? — 06 December 2010, 10:20
Another option could be imapsync. imapsync is what I use now. I moved from cyrus to dovecot. Thanks to those who add more information to help others.
nickt? — 04 December 2010, 10:29
I need to transfer from i386 to amd64 machine. My first attempt sort of failed.
I'll try this method.
Geoff? — 27 February 2009, 07:36
I moved from 32 to 64bit, adding these steps:
if moving to new architecture, first do on current server:
cd /var/lib/imap
mkdir flat
for f in *.db ; do /usr/lib/cyrus-imapd/cvt_cyrusdb $PWD/$f skiplist $PWD/flat/$f flat; done
then on new server after move do:
cd /var/lib/imap/flat
for f in *.db ; do /usr/lib/cyrus-imapd/cvt_cyrusdb $PWD/$f flat $PWD/../$f skiplist; done
(hope I didn't forget anything - that seemed to work great, thx for the page!)
rcamp? — 20 February 2009, 15:10
Thanks for the added info
— 19 February 2009, 13:57
Note this won't work when the host architecture changes too -- for that you'll have to first dump any non-text databases into "flat" format using cvt_cyrusdb on the old machine, then on the new machine do the reverse.
You may also have to do something similar if you change the configuration files or compile defaults to use any different database formats.
Nice job. Baltimore...southside...respect.
Thanks for taking the time to put this on the web. Just what I was looking for.