This documentation is for Dovecot v1.x, see wiki2 for v2.x documentation.
Differences between revisions 1 and 32 (spanning 31 versions)
Revision 1 as of 2007-03-19 20:48:22
Size: 1967
Editor: TimoSirainen
Comment:
Revision 32 as of 2009-03-15 22:35:11
Size: 5638
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Courier, Courier-IMAP =
Courier by default uses "INBOX." as private IMAP namespace, so it has exactly the same problems as described with UW-IMAP above. Again, if you want the migration to be transparent for IMAP clients, see ["Namespaces"] how to set namespaces to be Courier-compatible.
= Courier IMAP/POP3 =
Line 4: Line 3:
 * Courier's {{{courierimapsubscribed}}} is compatible with Dovecot's {{{subscriptions}}} file, just rename it and remove the "INBOX." prefixes. (NOTE: with 0.99.x it's {{{.subscriptions}}}, with 1.0 it's {{{subscriptions}}} without the dot)
 * Courier's {{{courierimapuiddb}}} is compatible with Dovecot's {{{dovecot-uidlist}}} file, just rename it.
 * Courier's message flags are compatible with Dovecot (as they are specified by the Maildir specification)
 * Courier's message keywords implementation isn't Dovecot compatible and there is currently no easy way to migrate them.
See also the [http://bendiken.net/scripts/ courier2dovecot] script by Arto Bendiken.
== Courier v0.43 and later to Dovecot v1.1+ ==
Line 10: Line 5:
See also the [http://www.aucontraire.net/scripts/mail/courier2dovecot.py courier2dovecot.py] script by Michael Watkins. [[http://www.dovecot.org/tools/courier-dovecot-migrate.pl|courier-dovecot-migrate.pl]] does a perfect migration from Courier IMAP and POP3, preserving IMAP UIDs and POP3 UIDLs. It reads Courier's {{{courierimapuiddb}}} and {{{courierpop3dsizelist}}} files and produces {{{dovecot-uidlist}}} file from it. Note that it works properly only with Dovecot v1.1 and later, see the next section for v1.0.
Line 12: Line 7:
Settings: Before doing the actual conversion you can run the script and see if it complains about any errors and such, for example:
Line 15: Line 10:
# normal home directories # ./courier-dovecot-migrate.pl --to-dovecot --recursive /home
Finding maildirs under /home
/home/user/Maildir/dovecot-uidlist already exists, not overwritten
/home/user/Maildir2: No imap/pop3 uidlist files
Total: 69 mailboxes / 6 users
       0 errors
No actual conversion done, use --convert parameter
}}}

The actual conversion can be done for all users at once by running the script with {{{--convert --recursive}}} parameters. Make sure the conversion worked by checking that {{{dovecot-uidlist}}} files were created to all maildirs (including to subfolders).

You can also convert each user as they log in for the first time, using PostLoginScripting with a script something like:

{{{
#!/bin/sh
# WARNING: Be sure to use mail_drop_priv_before_exec=yes,
# otherwise the files are created as root!

courier-dovecot-migrate.pl --quiet --to-dovecot --convert ~/Maildir
# This is for imap, create a similar script for pop3 too
exec /usr/local/libexec/dovecot/imap
}}}

== Courier v0.43 and later to Dovecot v1.0 ==

An older version of the [[http://www.dovecot.org/tools/courier-dovecot-migrate-1.0.pl|courier-dovecot-migrate-1.0.pl]] attempts to do as good migration from Courier as possible for Dovecot v1.0. If you're using only IMAP, the migration will be perfect, but with POP3 the IMAP UIDs or POP3 UIDLs may have to be changed.

Before the actual conversion, you can check how well it can be done:

{{{
# ./courier-dovecot-migrate-1.0.pl --recursive /home
Finding maildirs under /home
/home/tss/Maildir/courierpop3dsizelist: 2 / 2956 needs changing
/home/tss/Maildir/courierimapuiddb: 2956 / 2957 needs changing

Total: 2 POP3 changes, 2956 IMAP changes, 0 errors
}}}

This means that 2 POP3 UIDLs need to be changed (clients will download them as duplicates) and only one IMAP UID can be converted without changing it. Changing IMAP UIDs isn't as bad, it will only cause a somewhat heavier load to your mail server when the IMAP clients begin downloading the old mails again.

== Dovecot configuration ==

Courier by default uses "INBOX." as the IMAP namespace for private mailboxes. If you want a transparent migration, you'll need to configure Dovecot to use a namespace with "INBOX." prefix as well.

{{{
protocol pop3 {
  # If you used the v1.1+ migration script, you probably should keep using
  # the default pop3_uidl_format (%08Xu%08Xv) instead of changing this.
  pop3_uidl_format = UID%u-%v
}
Line 17: Line 62:
# for virtual users
mail_location = maildir:~/}}}
For POP3 UIDL compatibility with Courier, the Dovecot configuration depends on the Courier version used:

namespace private {
  prefix = INBOX.
  inbox = yes
}
}}}

== Manual conversion ==

 * Courier's {{{courierimapsubscribed}}} file is compatible with Dovecot's {{{subscriptions}}} file, but you need to remove the "INBOX." prefixes from the mailboxes.
 * Courier's {{{courierimapuiddb}}} file is compatible with Dovecot's {{{dovecot-uidlist}}} file, just rename it.
 * Courier's message flags are compatible with Dovecot (as they are specified by the Maildir specification)
 * Courier's message keywords implementation isn't Dovecot compatible. There doesn't exist a simple way to convert the keywords manually.

== Older Courier POP3 versions to Dovecot v1.0 ==

With the v1.1+ migration script you can use any pop3_uidl_format, because the UIDLs are stored directly in the dovecot-uidlist file.
Line 30: Line 89:
 Courier version 3 (younger versions):: Here everything has changed: Courier's UID data are now stored in{{{courierpop3dsizelist}}}and in a completely new format. But it's still possible to convert it to the format dovecot needs (link to perlscript and further configuration details will follow later).
== Dovecot v1.0, ManageSieve server and namespaces ==

Dovecot v1.0's [[LDA|deliver]] ignores namespaces, so [[LDA/Sieve|Sieve]] scripts shouldn't include namespace prefixes in '''fileinto''' destinations. If Sieve scripts are generated by some tool it probably includes these prefixes. If the script is uploaded via [[ManageSieve|ManageSieve server]] you can kludge around this problem by using the script below. Dovecot v1.1's deliver doesn't ignore namespaces and this must not be done with it.

First modify managesieve configuration in dovecot.conf to execute your script instead:

{{{
protocol managesieve {
  ..
  mail_executable = /usr/libexec/dovecot/managesieve-nsfix.sh
}
}}}

Then create the {{{/usr/libexec/dovecot/managesieve-nsfix.sh}}} script:

{{{
#!/bin/bash
# by Allan GooD: allan.cassaro (at) gmail.com
export PATH="/bin:/usr/bin"

CONF="/etc/dovecot/dovecot.conf"

/usr/libexec/dovecot/managesieve
ERR=$?

NAMESPACE="`grep prefix $CONF | head -n1 | awk '{print $3}'`"

if [ -h "${HOME}/.dovecot.sieve" ] && [ "${NAMESPACE}" ]; then
  FILE="${HOME}/`ls -l ${HOME}/.dovecot.sieve | awk '{print $11}'`"
  SIEVE="`sed s/${NAMESPACE}/''/g $FILE`"
  echo "${SIEVE}" > ${FILE}
fi

exit $ERR
}}}

Note that this script removes everything from the script matching the namespace prefix, so in some rare cases it might break the script.

Courier IMAP/POP3

Courier v0.43 and later to Dovecot v1.1+

courier-dovecot-migrate.pl does a perfect migration from Courier IMAP and POP3, preserving IMAP UIDs and POP3 UIDLs. It reads Courier's courierimapuiddb and courierpop3dsizelist files and produces dovecot-uidlist file from it. Note that it works properly only with Dovecot v1.1 and later, see the next section for v1.0.

Before doing the actual conversion you can run the script and see if it complains about any errors and such, for example:

# ./courier-dovecot-migrate.pl --to-dovecot --recursive /home
Finding maildirs under /home
/home/user/Maildir/dovecot-uidlist already exists, not overwritten
/home/user/Maildir2: No imap/pop3 uidlist files
Total: 69 mailboxes / 6 users
       0 errors
No actual conversion done, use --convert parameter

The actual conversion can be done for all users at once by running the script with --convert --recursive parameters. Make sure the conversion worked by checking that dovecot-uidlist files were created to all maildirs (including to subfolders).

You can also convert each user as they log in for the first time, using PostLoginScripting with a script something like:

# WARNING: Be sure to use mail_drop_priv_before_exec=yes,
# otherwise the files are created as root!

courier-dovecot-migrate.pl --quiet --to-dovecot --convert ~/Maildir
# This is for imap, create a similar script for pop3 too
exec /usr/local/libexec/dovecot/imap

Courier v0.43 and later to Dovecot v1.0

An older version of the courier-dovecot-migrate-1.0.pl attempts to do as good migration from Courier as possible for Dovecot v1.0. If you're using only IMAP, the migration will be perfect, but with POP3 the IMAP UIDs or POP3 UIDLs may have to be changed.

Before the actual conversion, you can check how well it can be done:

# ./courier-dovecot-migrate-1.0.pl --recursive /home
Finding maildirs under /home
/home/tss/Maildir/courierpop3dsizelist: 2 / 2956 needs changing
/home/tss/Maildir/courierimapuiddb: 2956 / 2957 needs changing

Total: 2 POP3 changes, 2956 IMAP changes, 0 errors

This means that 2 POP3 UIDLs need to be changed (clients will download them as duplicates) and only one IMAP UID can be converted without changing it. Changing IMAP UIDs isn't as bad, it will only cause a somewhat heavier load to your mail server when the IMAP clients begin downloading the old mails again.

Dovecot configuration

Courier by default uses "INBOX." as the IMAP namespace for private mailboxes. If you want a transparent migration, you'll need to configure Dovecot to use a namespace with "INBOX." prefix as well.

protocol pop3 {
  # If you used the v1.1+ migration script, you probably should keep using
  # the default pop3_uidl_format (%08Xu%08Xv) instead of changing this.
  pop3_uidl_format = UID%u-%v
}

mail_location = maildir:~/Maildir

namespace private {
  prefix = INBOX.
  inbox = yes
}

Manual conversion

  • Courier's courierimapsubscribed file is compatible with Dovecot's subscriptions file, but you need to remove the "INBOX." prefixes from the mailboxes.

  • Courier's courierimapuiddb file is compatible with Dovecot's dovecot-uidlist file, just rename it.

  • Courier's message flags are compatible with Dovecot (as they are specified by the Maildir specification)
  • Courier's message keywords implementation isn't Dovecot compatible. There doesn't exist a simple way to convert the keywords manually.

Older Courier POP3 versions to Dovecot v1.0

With the v1.1+ migration script you can use any pop3_uidl_format, because the UIDLs are stored directly in the dovecot-uidlist file.

Courier version 0
# Courier version 0 (using maildir filenames)
pop3_uidl_format = %f
Courier version 1
# Courier version 1 (UID)
pop3_uidl_format = %u
Courier version 2 and early Courier version 3
# Courier version 2 (UIDVALIDITY and UID - you most likely want this)
pop3_uidl_format = %v-%u

Dovecot v1.0, ManageSieve server and namespaces

Dovecot v1.0's deliver ignores namespaces, so Sieve scripts shouldn't include namespace prefixes in fileinto destinations. If Sieve scripts are generated by some tool it probably includes these prefixes. If the script is uploaded via ManageSieve server you can kludge around this problem by using the script below. Dovecot v1.1's deliver doesn't ignore namespaces and this must not be done with it.

First modify managesieve configuration in dovecot.conf to execute your script instead:

protocol managesieve {
  ..
  mail_executable = /usr/libexec/dovecot/managesieve-nsfix.sh
}

Then create the /usr/libexec/dovecot/managesieve-nsfix.sh script:

# by Allan GooD: allan.cassaro (at) gmail.com
export PATH="/bin:/usr/bin"

CONF="/etc/dovecot/dovecot.conf"

/usr/libexec/dovecot/managesieve
ERR=$?

NAMESPACE="`grep prefix $CONF | head -n1 | awk '{print $3}'`"

if [ -h "${HOME}/.dovecot.sieve" ] && [ "${NAMESPACE}" ]; then
  FILE="${HOME}/`ls -l ${HOME}/.dovecot.sieve | awk '{print $11}'`"
  SIEVE="`sed s/${NAMESPACE}/''/g $FILE`"
  echo "${SIEVE}" > ${FILE}
fi

exit $ERR

Note that this script removes everything from the script matching the namespace prefix, so in some rare cases it might break the script.

None: Migration/Courier (last edited 2009-12-05 22:17:08 by kronos)