I seem to have fixed this, but I'm not sure if there's a better way. I did it by:
- Going into each mailbox
- Deleting all cyrus* files
- Reconstructing the mailbox
Here's the script I used.
#! /bin/bash # Rebuild all cyrus imap mailboxes # rjm 20230723 # To be run by the cyrus user if [ $USER != "cyrus" ] then echo "This script should be run by the 'cyrus' user." exit fi # First, go to the top of the uuid mailboxes pushd /var/spool/cyrus/mail/uuid > /dev/null 2>&1 # Now go through all the mailboxes, ignoring comments for mbox in `cat /var/spool/cyrus/mailboxes.txt | sed -e '/^#/d'` do # Find its directory mbdir=`/usr/lib/cyrus/bin/mbpath $mbox` pushd $mbdir > /dev/null 2>&1 ls -la cyrus* # Now to reconstruct the mailbox rm -f cyrus* # Return to home directory popd > /dev/null 2>&1 # Now reconstruct the mailbox /usr/lib/cyrus/bin/reconstruct $mbox done popd > /dev/null 2>&1
You'll need to put a copy of /var/lib/cyrus/mailboxes.txt into /var/spool/cyrus, edit it as necessary to include only the mailboxes you want to fix (comments are allowed with '#'), and run this script as the cyrus user (or whatever runs imapd in your box).
You should probably shut down the imapd service before running this. Note that it could take quite a long time.