Subject Re: [firebird-support] Database corruption problem
Author Ann Harrison
Jason Hunter wrote:

>I am running Firebird 1.5 rc3 and one of the databases I use just died.
>
>It has been working fine up till now when all I get is "database.fdb is
>not a valid database".
>
>
That error means that the header page has been overwritten by
something. If you have and single file database and a backup of it,
restore the backup (elsewhere), set it to read-only (that's important),
copy the broken database somewhere else, and copy the first 1024 bytes
from the restored file onto the first 1024 bytes of the copy of the
broken database. That should allow you to backup the bad database,
unless whatever wrote over the header page didn't stop there. If you
see an error like "bad type page 2 (expected 10 found x) where x is some
number other than 10, then whatever wrote on the header wrote further.
You may safely copy the first three pages of the read-only database
onto the copy. (e.g. page size is 4096 * 3 = 12288).

Then check the first 1024 bytes of the original file - a hex editor is a
good choice - that may give you a clue about the source of the corruption.

If you've got a multi-file database, then you'll need to do your changes
on the original corrupted database and use the copy as the safeguard,
rather than vice-versa.

Regards,


Ann