How to repair a corrupt Firebird database?
Here's a short step-by-step walkthrough:
* disconnect users and disable incoming connections to the database (FAQ #64)
* make a copy of database file (or two copies) and work on that
* use GFIX with -v option to validate the database file
* use GFIX with -v and -f to do full validation
If problem is not too serious, you can try to backup the broken db and restore under a new name:
* use GFIX -mend to prepare corrupt database for backup
* use GBAK -b -g to backup the database. -g disables garbage collection (FAQ #41)
* use GBAK -c to restore backup to a new database.
If you succeed, you have fixed the problem and have a functional database. If not, you can try to create an empty database with the same structure and pump the data to it (see FAQ #20).
If you're interested in a more detailed information of the process, as well as explanation of some types of corruption, take a look at the following page:
http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_db_corr
If all fails, you can try IBSurgeon tool, which is able to fix most problems and extract data. Also, IBSurgeon's website has a detailed
explanation of causes of database corruption and ways to fix it:
http://ib-aid.com/option,com_content/task,view/id,58/Itemid,62/





The Firebird FAQ