Migrating from Courier Imap to Cyrus Imap (2.2) on Debian Sarge

Since using Courier IMAP Server over the last tree years I thought it´s time to move on.

At first, add these lines to /etc/apt/source.list:

deb http://mail.incase.de/cyrus22/ sarge main
deb-src http://mail.incase.de/cyrus22/ sarge main

Stopping MTA to prevent delivering new mails into Mailboxes.

# /etc/init.d/postfix stop

Install SASL2 and all needed cyrus components:

# aptitude install libsasl2 libsasl2-modules sasl2-bin
# aptitude install cyrus-admin-2.2 cyrus-clients-2.2 \
		cyrus-common-2.2 cyrus-imapd-2.2

/etc/default/saslauthd needs modified to start and use sasldb as userdb-backend:

START=yes
MECHANISMS="sasldb"

Now we need to modify /etc/fstab to allow chrooted postfix to interact with sasl and cyrus:

/var/run/saslauthd    /var/spool/postfix/var/run/saslauthd    none    rw,bind    0 0
/var/run/cyrus  /var/spool/postfix/var/run/cyrus        none    rw,bind 0 0

Mounting everything:

# mkdir -p /var/spool/postfix/var/run/saslauthd
# mkdir -p /var/spool/postfix/var/run/cyrus
# mount /var/spool/postfix/var/run/saslauthd
# mount /var/spool/postfix/var/run/cyrus

Modify /etc/postfix/sasl/smtpd.conf:

pwcheck_method: saslauthd
mech_list: plain login

Add an user "sasl":

# adduser postfix sasl

Add a transport to /etc/postfix/master.cf:

cyrus           unix    -       n       n       -       -       pipe
flags=R user=cyrus argv=/usr/sbin/cyrdeliver -e -m ${extension} ${user}

To make sieve listen to all network interfaces run:

# sed -i s/localhost:sieve/sieve/ /etc/cyrus.conf

Make the user cyrus to admin and use sasldb as auxprop plugin insert into /etc/imapd.conf:

admins: cyrus
sasl_auxprop_plugin: sasldb

Restart the daemons, set admin and user passwords in the sasl backend:

# /etc/init.d/saslauthd restart
# /etc/init.d/cyrus2.2 restart
# saslpasswd2 -p -c cyrus
# saslpasswd2 -p -c

Create mailboxes in cyrus:

# su - cyrus
$ cyradm localhost
host> cm user.foobar
host> exit
$ exit
logout

Make the lmtp transport working with postfix:

# addgroup lmtp
# adduser postfix lmtp
# /etc/init.d/postfix start

Now the cyrus imap server and the cyrus sasldb should be running fine. But this was the easiest part ... now you need to migrate the user mailboxes ... since courier uses mbox or maildir but cyrus its own maildir format, you need to sync the mailboxes over the imap protocol. This makes it necessary to have your account data of all your users in place, which maybe the biggest problem of the migration process. To sync the content of the mailboxes I copied the old courier mailboxes to a temporary courier imapserver and synced the content with imapsync.

The big advantages of cyrus are the better perfomance, multiple concurrent read/write connections to the same mailbox, storage quotas on mailbox hierarchies, sharing mailboxes with other users and the serverside filter engine which can be managed with Mailclients.

Disadvantages (of the sieve filter) are, that folders used to sort with sieve aren´t auto created and that there is no "$MATCH" support, like in procmail, which makes filtering mailinglists more difficult und the script much larger.

Reviewing the changes I´m happier with the actual solution. :-)

Show Comments