Table of Contents

Mirgrating courier

migrating whole Courier soulutions means basicly migrating only imap and maildrop deliverer. The rest pop3 and auth daemon are trivial.

Case Study

Original virtual maildir structure /var/mail/virtual/example.com/name.surname/Maildir has additional special path /Maildir at the end. New should map to /srv/mail/virtual/example.com/name.surname/Maildir

First Solution for simple cases is simple. In simple case all your e-mails user@domain match the structure above (/path/domain/user) and maildir column in your database is funny overhead. Add to your dovecot.conf

auth default {
  ...
  userdb static {
      args = uid=1001 gid=1001 home=/srv/mail/virtual/%d/%n allow_all_users=yes
  }
  ...
}
mail_location = maildir:~/Maildir

Second Solution is to change the sql query int dovecot-sql.conf

user_query = SELECT maildir as home, uid, gid, concat('maildir:', maildir, '/Maildir') as mail FROM mailbox WHERE username = '%u'

and set up different userdb source in dovecot.conf

auth default {
  ...
  userdb sql {
    args = /etc/dovecot/dovecot-sql.conf
  }
  ...
}

forget the mail_location.

Theory Behind

Is that realy a theory? It is the code behind. Final deliverer LDA is deliver. It is given one parameter -d {recipient which is -d name.username@example.com. First it asks dovecot auth socket for additional data like uid, gid, maildir path.

Syncing Dirs

at source host:

for i in /var/mail/virtual/*/; do echo $i; rsync -a  --rsh='ssh -c blowfish' $i wd@81.0.212.153:$i; done

at new host:

./courier2dovecot.pl --to-dovecot --convert --recursive /var/mail/virtual/*