Botched Debian upgrades, converting a Cyrus IMAP mail spool to Maildir format

Remember: you should always try to use Debian codenames (i.e. etch, lenny, squeeze) and not "stable" in your /etc/apt/sources.list file (see also the hint in the Debian release notes). Cause if you don't new Debian releases are nothing to look forward to...

A colleague of mine accidentially started upgrading to Debian 6.0 (squeeze) because he had "stable" in the configuration, and since it was a VPS (virtual private server) where he can't choose his own kernel version the upgrade failed with ldconfig dying with "FATAL: kernel too old" while configuring the package libgcc1.

Anyway, since the system was meant to be retired anyway, the next step was to get all the data off the system. But, since the upgrade got stuck in the middle, the Cyrus IMAP server wasn't working any more, so there was the need to get the old mails to the new, shiny IMAP server, which is running Dovecot.

So, after checking cyrus2courier first (because that was found first when searching for how to convert to Maildir) I stumbled over the link to cyrus2dovecot in the migration section of the Dovecot wiki. And this tool worked flawlessly.

After copying /var/{lib,spool}/cyrus from the old Debian lenny machine to /home/cyrus/{lib,spool}/cyrus on the new mail server, I just ran

cyrus2dovecot --cyrus-inbox /home/cyrus/spool/cyrus/mail/%h/user/%u \
              --cyrus-seen  /home/cyrus/lib/cyrus/user/%h/%u.seen   \
              --cyrus-sub   /home/cyrus/lib/cyrus/user/%h/%u.sub    \
              --dovecot-inbox /home/cyrus/dovecot/%u/Maildir        \
              user1 user2 user3 ...

After waiting for the conversion to finish (time varies depending on the number of mails/users), voila: perfectly converted Maildir-formatted mails in /home/cyrus/dovecot/*/Maildir. Just move them to the actual locations (if you're feeling lucky, you can also change --dovecot-inbox to suit your final destination), and you're done.

Comments

Anonymous's picture

this works flawlessly. save by *ss big time!