Hi Jack,
You should be able to export the mailboxes database on the old server to
text and then import on the new server. In package of cyrus we are
running, the DB export is actually done daily automatically.
Here is an approximation of what we did last time we did a
server/version migrat
We use a perl scrip that does similar process to delete mass phishing or
malware email messages from the mail spool. The script locates the
sequence number for the message based on the message ID/filename, and
then issues the IMAP delete and expunge commands.
Relevant section of code below