Koozali.org: home of the SME Server

IMAP emails cannot be restored

Rod Lopez

IMAP emails cannot be restored
« on: May 06, 2007, 11:45:38 AM »
Hi All,

A client's SME Server 7 failed, and we had to restore all the data from backups using a fresh install (had to recreate user accounts too).  Everything seems to work fine, but the IMAP emails.  Here are my observations:

    1. - The Maildir folder for the user has all the hidden email files, such as .imap.index.data (when we cat this we can see the emails in there).
    2.- The ownership and permissions of all files are correct for the new user.
    3.- The file dovecot-uidlist has an entry for each email in the .imap.index.data file.
    4.- When the email client (Outlook Express) connects to the SME IMAP Server and synchronizes, it downloads all the folders and it even shows how many unread emails are in each folder.
    5.- When you actually open the folder, there is nothing inside, and the folder then clears the number of unread emails (same happens through webmail so it is not the client).


My guess is that the SME Server goes through the list of emails on the file dovecot-uidlist and compares that with .imap.index.data and then rejects all emails as illegitimate (maybe checksums don't agree, or somehow the emails are linked to the UID of the previous account), so they are not displayed by the email client.  I even tried to pop the emails using Outlook POP3, so I could restore them from the PST file to the IMAP account, but nothing was popped - as no emails are visible from IMAP)

I am very new to SME Server, so I am not too sure how to proceed from here.

But does anyone know how to restore the emails, or force SME to accept them, rebuild the indexes on Maildir, export the Maildir format to anything else and then back again, or anything else I could try?  Any help is greatly appreciated.

Cheers

Rod

Offline mmccarn

  • *
  • 2,656
  • +10/-0
IMAP emails cannot be restored
« Reply #1 on: May 06, 2007, 07:03:30 PM »
I was able to access a "restored" mailbox like this:
1) Create the new mailbox:
    mkdir /home/e-smith/files/users/<username>/Maildir/.test
    mkdir /home/e-smith/files/users/<username>/Maildir/.test/cur

2) Copy the old email messages:
    cp <oldmailbox>/cur/* <newmailbox>/cur

3) Change permissions:
    chmod -R <user>:<user> <newmailbox>


The "test"mailbox then appeared in a configured Thunderbird mail client and could be accessed with no problem.

This suggests that you could simply delete the various dovecot... and imap index files in order to get your mailbox back -- but I suspect you'll lose all message status information...

Quote
1. - The Maildir folder for the user has all the hidden email files, such as .imap.index.data (when we cat this we can see the emails in there).
The actual emails are stored in separate files within each "cur" folder, not in the .imap.index.data file you mentioned...  For the "Inbox", this is <username>/Mailbox/cur; for other folders this is <username>/Mailbox/.folder/cur.  Have you restored the 'cur' folder for each mailbox?

Rod Lopez

IMAP emails cannot be restored
« Reply #2 on: May 06, 2007, 08:58:36 PM »
YES, that's it!  :idea:   I just woke up about 20 minutes ago, and the same thing crossed my mind:

The .imap.index* files must be just indexes for fast searching and Dovecot can recreate these again if needed.
The dovecot-uidlist file is the message list with each line pointing to each message file in the cur directory.
So I just have to find the files listed in there and restore these!

I thought I would put my new thoughts here, but I think you beat me to it!  :wink:
I'll check the backups at work for these files. But now I can go back to sleep...

Offline byte

  • *
  • 2,183
  • +2/-0
IMAP emails cannot be restored
« Reply #3 on: May 06, 2007, 11:09:10 PM »
And remember if something is broke, please report to bug tracker. Thanks!
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!