Cyrus Mailbox Reconstruction (OS X)

From The System Administrator Zone

The is based on an apple support article. I copied it over here as a starting point to clarify the documentation. It didn't quite work for me as described. I am only including the section on server 10.4.x as I don't have a 10.3 system.

Mac OS X Server 10.4.x

Stopping and Starting the Cyrus mail server

    $ sudo serveradmin stop mail
    $ sudo serveradmin start mail

Reconstructing all cyrus user mailboxes

To reconstruct the cyrus mail database in Mac OS X Server 10.4, use the Repair button in the Maintenance tab of the Mail module in Server Admin. If issues persist after reconstructing the database via Server Admin you can follow the steps listed below to manually reconstruct the mail database.

  1. Stop the cyrus (IMAP/POP) server.
  2.     $ sudo serveradmin stop mail
  3. Execute these commands in Terminal:
  4.       $ su root
          # mv /var/imap /var/imap.old
          # mkdir /var/imap
          # /usr/bin/cyrus/tools/mkimap
          # chown -R cyrusimap:mail /var/imap
          # sudo -u cyrusimap /usr/bin/cyrus/bin/reconstruct -i
  5. Restart the cyrus (IMAP/POP) server, and verify that mail is working.
  6.     $ sudo serveradmin start mail
  7. If a mailbox is missing for a particular user account, delete the account from the mail application at the client computer, quit the mail application, then reconfigure it (alternatively you could configure a mail client that has not been used with this account before).

WARNING:This does not copy or recreate the .seen files, which means when you click on a folder, a new index will be created and everything will be listed as unread.

Reconstructing a single cyrus user mailbox

This does not seem to have a negative impact on the user's .seen status. However, you will still need to subscribe to non-visible folders.

  • Stop the cyrus (IMAP/POP) server.
    $ sudo serveradmin stop mail
  • Execute this command in Terminal:
      $ sudo -u cyrusimap /usr/bin/cyrus/bin/reconstruct -i user/(short name)
An updefined option that is recommended in all Apple instructions. It appears to be a combination of -r, -f and others.
Recursively reconstruct all sub-mailboxes of the mailboxes or mailbox prefixes given as arguments.
Examine the filesystem underneath mailbox, adding all directories with a cyrus.header found there as new mailboxes. Useful for restoring mailboxes from backups.
  • Start the cyrus (IMAP/POP) server.
    $ sudo serveradmin start mail

Folders not visible in Outlook

Often, folders are not visible in outlook and rebuilding the user's mailbox doesn't seem to help, even though the directories are readily visible on the server. Outlook does not always subscribe to new folders.

Unlike Internet e-mail protocols such as POP3, IMAP creates folders on a server to store/organize messages for retrieval by other computers. You read message headers only and select which messages to download. Headers are only downloaded for the folders you have subscribed to.

  1. In Mail, in the Navigation Pane, click the Inbox for the Cyrus server account that contains a folder you want to subscribe to or unsubscribe from.
  2. On the Tools menu, click IMAP Folders.
To Subscribe
  1. Click Query.
  2. In the Folders box, click the folder you want to subscribe to. To select multiple folders, hold down CTRL while clicking folder names.
  3. Click Subscribe.
To Unsubscribe
  1. Click the Subscribed tab.
  2. Click Query.
  3. In the Folders box, click the folder you want to unsubscribe from. To select multiple folders, hold down CTRL while clicking folder names.
  4. Click Unsubscribe.


You may want to try mailbfr:

Summary of Apple Support Efforts

Based on my last discussions with the Apple support engineer, we came to the conclusion that there is current no fix to our problem. I ended up created new accounts for those individuals who were experiencing the 'Over quota' problem.

The proof that the 'Over quota' error is a false error lies in the fact that users who were flagged as being over their quota;

  1. were not those with the most mail on the system
  2. were able to copy all of the messages from the account that was over quota to their new account without tripping the over quota flag.

This is a real system bug that the engineer agreed to pass on to the software development team for diagnosis and repair. Creating new accounts was an acceptable work-around in our environment, simply because we had less than 100 users. It could be disasterous in a larger environment.

Corrupted SEEN files

After a system disk hit 100%, I started seeing the following errors in /var/log/system.log.

Apr  2 18:53:56 HOSTNAME imap[1981]: DBERROR: skiplist recovery 
/Volumes/raid1/mail_server/database/user/p/USERNAME.seen: ADD at 1FE8 exists
Apr  2 18:53:56 HOSTNAME imap[1981]: DBERROR: opening 
/Volumes/raid1/mail_server/database/user/p/USERNAME.seen: cyrusdb error
Apr  2 18:53:56 HOSTNAME imap[1981]: Could not open seen state for USERNAME (System I/O error)

If you truncate the file at this point, it should fix the problem. The users mail read state will be valid up to the point of corruption.

To do this, first convert the hex to decimal. You can use the Unix bc command:

$ echo "ibase=16;1FE8" | bc

Then, using the Unix dd command, you can truncate the file and replace the corrupted .seen file with the fixed one. Have user log in and check that everything is ok.

# dd if=USERNAME.seen of=USERNAME.seen.fixed bs=1 count=8168
# mv USERNAME.seen USERNAME.seen.corrupt
# mv USERNAME.seen.fixed USERNAME.seen