Managing Cyrus Mailboxes
Because CyrusImap is an all in one solution there are some new tricks for managing Cyrus based mailboxes.
Contents
Howto Rebuild a Mailbox
- Make sure the user has closed their email client (if they are using Mozilla/Netscape this includes any browser or other component windows).
- Log in to the mail server as _root_
- Find any processes attached to the users mailbox and kill them:
# find /var/spool/imap/user/<username>/ -name "cyrus.*" -print -exec fuser -k {} \; - Reconstruct the users mailbox:
# su - cyrus -c "./reconstruct -r user.<username>"
- Once it has finished they should be good to go!
Fixing System I/O Errors
All Cyrus user mail directories must be manipulated via an IMAP client, not directly via the commandline with mv/rm/etc. If someone manually removes a directory then you will get I/O errors like this:
root# su - cyrus cyrus> ./reconstruct -r user.adam user.adam user.adam.Drafts: System I/O error No such file or directory
The Cyrus "user.adam.Drafts" expands to the /var/spool/imap/user/adam/Drafts directory and if you look you should find that it doesn't exist. In order to fix the problem you need to create each missing directory by hand (and make sure to remember to chown them to the cyrus user).
Restoring Mail Folders from Backup
Sometimes you need to recover mail folders from backups (either the rsync backup or from tape). If you are recovering a folder which Cyrus no longer knows about (eg. because it was deleted accidentally via an IMAP client) then you need to use the reconstruct command to tell cyrus that there is mail for it in that folder.
- Copy the recovered data back to it's new home
# rsh bruinen # cp -r /snapshot/adam/deleted /var/spool/imap/user/adam/recovered_backup # chown -R cyrus:cyrus /var/spool/imap/user/adam/recovered_backup
- Run a reconstruct on the mailbox using the -r and -f options to tell Cyrus to update the mailboxes.db file which is how it knows what folders exist in every users mailbox (NOTE: "reconstruct -f -r" does not work, you must run "reconstruct -rf" as shown).:
# su - cyrus -c "./reconstruct -rf user.adam" discovered user.adam.recovered_backup user.adam user.adam.Sent ...
If the recovered_backup folder has any subfolders you need to run the reconstruct command again so that Cyrus can find the sub-folders (repeat for sub-sub-folders):# su - cyrus -c "./reconstruct -rf user.adam.recovered_backup" discovered user.adam.recovered_backup.foo discovered user.adam.recovered_backup.bar user.adam user.adam.Sent ...
- Check to make sure that the folders are showing up in the mailboxes.db file correctly.
# su - cyrus -c "./ctl_mboxlist -d /var/lib/imap/mailboxes.db | grep user.adam.recovered" user.adam.recovered_backup default adam lrswipcda user.adam.recovered_backup.foo default adam lrswipcda user.adam.recovered_backup.bar default adam lrswipcda ...