Subject: Recovery options for a corrupt mbx format folder

From: Guy Dawson <[email-masked]>
Date: Wed, 19 Sep 2001 16:07:29 +0100

Hi,

We have a 100MB IMAP mail folder in mbx format which is corrupt.

When running icat (or any other c-client program) on it I get the
following message

?Unable to parse internal header at 5097016: flight.co.uk

The file in question is readable (it can be copied to /dev/null or another
file) we just can't read the messages.

Is there any way the messages can be dumped to another file and then
reloaded into a new mbx file?

This is with IMAP 4.7c BTW. Does the latest version have any folder
recovery utilities?

TIA,
Guy
-- --------------------------------------------------------------------
Guy Dawson                    I.T. Manager              Crossflight Ltd
[email-masked]         07973  797819                01753 776104

**********************************************************************
This email contains the views and opinions of a Crossflight Limited
employee and at this stage are in no way a direct representation of
Crossflight Limited.

This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager. To ensure the integrity and appropriate use of
its email system, Crossflight Limited reserves the right to examine
any email held on its email system or sent to or from it.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

We strongly recommend that you check this email with your own virus
software as Crossflight Limited will not be held responsible for any
damage caused by viruses as a result of opening this mail.
**********************************************************************

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Sebastian Hagedorn <[email-masked]>
Date: Wed, 19 Sep 2001 17:20:40 +0200

No, but you can repair it yourself (I'm quoting Mark Crispin):

> There currently isn't an mbx format document, but the format is pretty
> straightforward.  Assuming that the 2K header is OK, each message has a
> one line internal header of the form
> 	date,size;flags-uid
> where
> date	date in "dd-mmm-yyyy hh:mm:ss [+-]zzzz" format
> size	exact size of message in octets
> flags	message flags as 12 hex digits (32-bit keywords, 16-bit system
> flags) uid	32-bit message UID as 8 hex digits
>
> Then comes the message, using CR/LF style newlines.
>
> Another internal header or end-of-file is expected exactly <size> bytes
> later. If it isn't, that's corruption.  So fixing a corrupted mbx file
> involves finding the places where an internal header was expected but did
> not occur, and then deleting whatever is necessary to make sure that one
> occurs at that position.
>
> c-client will usually indicate the byte position in the file where
> corruption has taken place, so an editor such as emacs can be used to fix
> things up.  You probably won't be able to use vi.

Have you used mbx on an NFS volume? That's not supported...

Cheers, Sebastian
--
Sebastian Hagedorn
Ehrenfeldgürtel 156
50823 Köln
http://www.spinfo.uni-koeln.de/~hgd/

---

From: Guy Dawson <[email-masked]>
Date: Wed, 19 Sep 2001 16:24:46 +0100

> No, but you can repair it yourself (I'm quoting Mark Crispin):

Thanks for the info. IMHO a recovery program would be a really
useful addition to the c-client library.

> Have you used mbx on an NFS volume? That's not supported...

No, it's on a SCSI RAID array.

I think I might have to get my programming head on.

Guy

---

From: Guy Dawson <[email-masked]>
Date: Wed, 19 Sep 2001 18:49:50 +0100

> I think I might have to get my programming head on.

I've written a program and have recovered all the messages. One of
them appears to have been split in two though!

The program uses the regex/regcomp expression matching function on UNIX
to go through the mbx format file line by line.

Each time it finds a message header of the form

11-Sep-2001 15:31:05 +0100,2476;000000000000-0001c0f1

it outputs a couple of blank lines and then a line in the form

>From MAILER-DAEMON Thu Sep 19 06:38:46 2001

followed by the email message. It continues to do this until all of the
file has been read.

A little editing to remove the odd spurious ^M character and the
result is a UNIX format mail file. This can then be converted back
into mbx format using mbxcvt.

If anyone would like a copy of the program source please email
be direct...

Guy