Using imapsync to move mails from your old to your new server

If you read my book Mac OS X Server 10.5 als Groupware-Server and built up your own personal Mac OS X mail server, you might want to move existing email data to your new server.

If your server serves mails for a couple of users only, you can do this using your mail client: simply point it to you old mail server as well as to your new machine and move data within your mail application. This has to be done for each user.

If you support multiple users, you might want to automate the data migration without user interaction.

One way to do this is to use the perl app imapsync, which can be found at http://freshmeat.net/projects/imapsync/.

This short article explains how we migrated about 2000 mail accounts including existing emails and subfolders from a Novell IMAP server to a 10.4 mail server. This should work fine with a 10.5 server, too.

Install imapsync

First you need to install imapsync. This can be either done on any Mac OS X client or the server itself. If you use a Mac OS X client, mails will be copied from the old server to the client and then to the new server, so the most effective way for big mail servers would be to install imapsync on the server as there’s less network traffic necessary on the ethernet interface if you copy data only once.

The easiest way to do install imapsync is to use MacPorts for the installation procedure.

If you haven’t done so before, get your copy of MacPorts at http://www.macports.org/install.php. The easiest way is to use the Mac OS X package installer, which automatically updates MacPorts to the latest branch during installation.

imapsync needs the Perl module MAIL::IMAP-Client version 2.2.9 as a prerequisite, which you can download from http://search.cpan.org/CPAN/authors/id/D/DJ/DJKERNEN/Mail-IMAPClient-2.2.9.tar.gz. Unzip the downloaded file, cd into the folder “Mail-IMAPClient-2.2.9″ and type:

perl Makefile.PL

After this command has completed, type

make install

Now use MacPorts to actually install imapsync:

port install imapsync

After installation you find imapsync at /opt/local/bin/imapsync.

imapsync has a lot of options available. Read

imapsync --help

to learn the details.