Você está na página 1de 2

Contribute : Advanced Search : Directory : Forum : FAQ's : My Downloads : Links : Polls

Changing the world one server at a time.

Welcome to AFP548
advanced search Tuesday, May 03 2011 @ 03:02 pm MDT

Cyrus IMAP Mailbox Recovery


Sections
Tuesday, August 24 2004 @ 07:37 am MDT
Home Contributed by: Aaron
AFP548 Site News (108/2) Views: 56,521
Articles (292/35)
I've occasionally encountered IMAP mailboxes that were unreadable and undeletable using any mail client. In Mac OS X Mail, this
Apple (54/2)
usually produces an "Unable to Select" error.
Extended KB (3/1)
Ask AFP548 (16/48) Here's how to fix the server-side mailbox. At the bottom is a bonus: how to recover the locally cached .imapmbox file from Mail.
Reviews (5/2)
Security (17/2)
Tips (134/9)
Third Party Applications (58/7)
I learned how to do these steps from two web pages: Bynari Support and Code Comments.
Odds and Ends (28/1)
Podcasts (2/0) Step 1: Backup the locally-cached mail

The file will be inside ~/Library/Mail/IMAP-email-address, with an extension ".imapmbox". Copy this file to your Desktop.

User Functions Step 2: Repairing the Cyrus folder

Username: 1. Use Server Admin to stop the mail server


2. Change to root, and enter the directory /var/imap:
Password:
# sudo -s
# cd /var/imap

3. backup mailboxes.db:
Don't have an account yet? Sign up
as a New User # cp mailboxes.db mailboxes.db-backup
Lost your password?
4. Using Workgroup Manager, set user cyrus's shell to bash

(Ed. note: Rather than give cyrus a shell you could just use

Poll
sudo -u cyrus
What's your favorite
OpenSource management tool?
to do the following steps.)
radmind
Puppet 5. su to cyrus, and dump the database to a text file:
Munki # su cyrus
Results # /usr/bin/cyrus/bin/ctl_mboxlist -d > /tmp/mboxlist.txt

73 votes | 1 comments 6. Edit the text file and remove the lines that contain the problem folders:
# pico /tmp/mboxlist.txt

7. remove mailboxes.db:
Hosting Provided By:
# rm mailboxes.db

8. rebuild mailboxes.db from the new text file:


# cat /tmp/mboxlist.txt | /usr/bin/cyrus/bin/ctl_mboxlist -u

9. Reconstruct all mailboxes


# /usr/bin/cyrus/bin/reconstruct -r -f user

If there are any remaining folders that print an error, they'll be listed when performing cyrus reconstruct: (ie.. user.someuser:
Mailbox does not exist).

10. Exit back from cyrus and root


# exit
# exit

11. Using Workgroup Manager, set user cyrus's shell back to /usr/bin/false.
12. Restart Mail using Server Admin

Step Three: Recovering a locally-cached imapmbox

1. Create a fake imap email account. Don't use a real name or password. We want the account to remain offline.

2. Quit Mail

3. In the Finder, open the directory holding the newly-created INBOX.imapmbox file (It's in ~/Library/Mail/IMAP-something/").

4. Move this (empty) INBOX.imapmbox to the trash.

5. Move the cached mail file you had copied to the Desktop to this folder. Rename the file to "INBOX.imapmbox".

6. Start Mail again, and click on the new account name. Your messages should reappear.

7. Copy the messages from this folder to another one, either IMAP or locally.

8. In Mail's preferences, delete the account you had created.

Make sure you keep this fake account offline, or else Mail will overwrite your cached mailbox with an empty one!
2
What's Related Story Options
Bynari Support Printable Story Format
Code Comments
More by Aaron
More from Articles

Advertising

Cyrus IMAP Mailbox Recovery | 11 comments | Create New Account

The following comments are owned by whomever posted them. This site is not responsible for what they say.
Cyrus IMAP Mailbox Recovery
Authored by: hkmacs on Thursday, August 26 2004 @ 04:05 am MDT
I'm having a problem whereby now after running the server quite happily for
4 months if I create a new user on the Server in Mail when I try to access the
account I get "IMAP command “SELECT” failed" so I'm presuming this is the
same problem. However when I follow your steps, when I enter su cyrus, I get
su:Sorry. What am I doing wrong?
[ Reply to This | # ]
Cyrus IMAP Mailbox Recovery - Authored by: macshome on Thursday, August 26 2004 @ 11:23 pm MDT
Cyrus IMAP Mailbox Recovery - Authored by: jerkyjerk on Tuesday, August 31 2004 @ 05:50 pm MDT
Cyrus IMAP Mailbox Recovery - Authored by: Anonymous on Saturday, February 05 2005 @ 11:14 pm MST
Recovering one user's mailbox
Authored by: rshah on Thursday, October 07 2004 @ 11:57 pm MDT
To reconstruct one mailbox just use this command
sudo -u cyrus /usr/bin/cyrus/bin/reconstruct -r -f user/xxx

I found this at:


http://www.macosxhints.com/article.php?story=20040914201805804

and remember to stop the server before doing this


[ Reply to This | # ]
Recovering one user's mailbox - Authored by: Anonymous on Wednesday, April 12 2006 @ 02:50 am MDT
Recovering one user's mailbox - Authored by: Anonymous on Wednesday, January 17 2007 @ 07:47 pm MST
Recovering one user's mailbox - Authored by: Anonymous on Saturday, November 14 2009 @ 03:16 am MST
Cyrus IMAP Mailbox Recovery
Authored by: Anonymous on Wednesday, November 30 2005 @ 03:48 pm MST
This operation just save my life! Thanks!
[ Reply to This | # ]
Cyrus IMAP Mailbox Recovery - Authored by: davidss on Thursday, May 08 2008 @ 02:36 am MDT
Cyrus IMAP Mailbox Recovery
Authored by: Anonymous on Tuesday, January 27 2009 @ 07:45 am MST
Thank you guys. You've saved my day. Over a month I have got curious errors like

deliver[23437]: DBERROR: dbenv->open '/var/lib/imap/db' failed: Permission denied


deliver[2222]: DBERROR: dbenv->open '/var/lib/imap/db' failed: Permission denied
Jan 27 11:58:53 f2 deliver[2222]: DBERROR: init() on berkeley
Jan 27 12:02:20 f2 deliver[2766]: DBERROR: dbenv->open '/var/lib/imap/db' failed: Permission denied
Jan 27 12:02:20 f2 deliver[2766]: DBERROR: init() on berkeley
Jan 27 12:02:47 f2 deliver[2828]: DBERROR: dbenv->open '/var/lib/imap/db' failed: Permission denied
Jan 27 12:02:47 f2 deliver[2828]: DBERROR: init() on berkeley

or

ctl_cyrusdb[25540]: DBERROR: archive /var/lib/imap/db: cyrusdb error


Jan 27 10:56:04 f2 ctl_cyrusdb[25540]: DBERROR: error archiving log file: /var/lib/imap/db/log.0000000333
Jan 27 10:56:04 f2 ctl_cyrusdb[25540]: DBERROR: archive /var/lib/imap/db: cyrusdb error
Jan 27 10:56:04 f2 ctl_cyrusdb[25540]: DBERROR: error archiving database file: /var/lib/imap/mailboxes.db
Jan 27 10:56:04 f2 ctl_cyrusdb[25540]: DBERROR: archive /var/lib/imap/db: cyrusdb error
Jan 27 10:56:04 f2 ctl_cyrusdb[25540]: DBERROR: error archiving log file: /var/lib/imap/db/log.0000000333
Jan 27 10:56:04 f2 ctl_cyrusdb[25540]: DBERROR: archive /var/lib/imap/db: cyrusdb error

I tried db_recover on the db files with no results. After reconstructing my mailboxes.db file, which contained one bad subfolder, all errors
vanished. Thank you! Gerhard Lehmann
[ Reply to This | # ]

Copyright © 2011 AFP548 Powered By Geeklog


All trademarks and copyrights on this page are owned by their respective owners. Created this page in 0.16 seconds

Você também pode gostar