IBSurgeon FirstAID is the tool that can automatically diagnose and repair corrupted Firebird databases - it can recover corruptions that neither gbak nor gfix can fix. Supported versions: Firebird 5.0, 4.0, 3.0, 2.5, 2.1, 2.0, 1.5, 1.0.
It uses its layer for low-level database access without using the Firebird engine, so it can perform real "surgical" operations and repair your database when all other standard mechanisms (gfix and gbak) cannot.
Now you are just 5 minutes away from recovering your corrupted Firebird database!
Open the corrupted database with FirstAID and double click on the table name, then browse through the table's data pages.
If you decide to recover the data you see in FirstAID, purchase the license (you'll get your license information in automatic email in 15 minutes after completing the purchase). What you see is what you will recover with FirstAID.
What is database corruption and how FirstAID repairs it?
Usually, database corruption means that some links between internal structures of Firebird (or InterBase) database are broken. When the database engine sees a broken reference to the missed record or database page, it stops working with a message like this:
Such error messages are reported by gbak tool, by gfix (it writes them into firebird.log), and by end-users applications.
The first part of this error is a common prefix for bugcheck (i.e., serious error), and in the parentheses, there are details of the error.
Usually, such error prevents normal work with the database, and the recovery procedure should be executed. If it was not possible to fix a corrupted Firebird (or InterBase) database with standard means (gfix.exe and gbak.exe), it is time for IBSurgeon FirstAID.
IBSurgeon FirstAID is designed to work with the database directly, on a very low level – it allows bypassing erroneous places where the engine crashes and either fix broken links or exporting all users' data to the new database.
Technical requirements
FirstAID is a Windows application designed to recover databases from both Linux and Windows Firebird instances. To recover a database from a Linux server, simply copy the database file to a Windows machine where FirstAID is installed. System Requirements:
Operating System: Windows 7 or later
Memory: 8GB RAM or more recommended
Storage: SSD drive recommended for faster recovery operations
Two options to recover Firebird or InterBase database with FirstAID
IBSurgeon FirstAID can perform 2 kinds of recovery operations: direct recovery and data extraction. The direct recovery is intended to fix the original corrupted database in place. This is a very fast and efficient method: after fixing the broken links database usually becomes readable, and it is possible to perform backup and restore. There are detailed instructions in FirstAID Recovery Guide on how to use the direct fix in FirstAID and then perform final steps with gfix and gbak tools.
The data extraction is designed to view and export data from the corrupted database to the database with the same structure (usually it should be empty).
FirstAID data extraction is applied in the case of heavy corruptions or metadata losses: it uses only a few system tables to decrypt users' data and export all available data to the new database.
Important!You can download the free version of FirstAID, open the corrupted database and preview all available data – and if you can see these data, they can be saved and exported to the new empty database. FirstAID scans corrupted database, then shows the list of tables, so a user can browse them.
With IBSurgeon FirstAID it is possible to repair corrupted Firebird/InterBase databases in more than 95% of cases.
See the video below how to repair the Firebird database with IBSurgeon FirstAID:
Common Firebird corruptions and their error codes
There are many possible corruptions that IBSurgeon FirstAID has been designed to repair and correct. These are listed below:
Internal gds software consistency check (cannot find tip page (165)) The required Transaction Inventory Page is corrupt and the database cannot be opened. Firebird error code (bugcheck number) is 165. It is expected in this instance that neither gbak nor gfix will be able to repair your database (except in the case of a Read-Only database). IBFirstAID will repair the missing pages and recover the database. It should be fixed with FirstAID Direct.
Database file appears corrupt (). bad checksum. checksum error on database page. gds_$receive failed This error is reported by gbak, it indicates corruption caused by lost or zeroed pages: Firebird cannot find checksum placeholder (it is 12345 since InterBase 5.x) and reports any other value of as "bad". It can be fixed with Direct Fix or, in the case of heavy corruption, with extraction.
Internal gds software consistency check (decompression overran buffer (178)....) One or more records are damaged. Data should be exported from the corrupted database with FirstAID extraction.
Internal gds software consistency check (wrong record length (183)...) One or more records are damaged: the actual length of the record is different from declared one. The data from the corrupted database should be exported with FirstAID extraction. Bugcheck number (error code for this error) is 183.
Unknown database I/O error for file "*.gdb". Error while trying to read from the database file. This usually indicates that many database pages have probably been lost at the end of the database file (power failure?). In this case, the database cannot be opened. Gfix cannot repair this. IBFirstAID will recreate the missing system pages and deletes the wrong pointers.
Database file appears corrupt. Wrong page type. Page NNN is of wrong type (expected X, found Y). Or, another variant of this error: Page ... is of wrong type (expected ..., found purposely undefined) This error can indicate several problems. But typically there are missing pages in the database or the page that is being accessed is not the expected page type. For example, if the expected page type is 5, it can mean that some data may have been corrupted within a table. Such corruption may prevent a successful backup or may make the table unavailable to the database. IBFirstAID fixes the wrong page pointers and repairs the database.
Fragmented record NNN is corrupt in table TABLE(NNN) One or more fragmented records lost their fragments, so the whole record cannot be assembled from fragments. In this case, data should be exported from the corrupted database with FirstAID extraction.
Wrong record length. Cannot find backversion. IBFirstAID will check every record in a database and will try to repair these record-level errors.
internal gds software consistency check (pointer page vanished from mark_full (256), file: dpm.cpp line: 3240) Serious corruption, data export with FirstAID is recommended.
Invalid request BLR at offset NNN. This error occurs in a case of corrupted or incompatible BLR (Binary Language Representation) of some stored procedure, trigger, or view in the database. Ideally, this error should be fixed with the recompilation of appropriate database objects, but in the case of the persisting problem, the full export to the new good database is required. The peculiarity of this error is that backup/restore with gbak does not fix it since BLR is not recompiled automatically during backup/restore.
Incremental backup (nbackup) merge errors, like this:
[
PROBLEM ON "end backup".
unsuccessful metadata update
-ALTER DATABASE failed
-Database is not in the physical backup mode
SQLCODE:-607
]
Other database corruptions can be caused by lost pages, corrupted records, metadata problems, etc. The full list of Firebird errors and their codes are here.
Video materials
Remember that purchasing services and products in Firebird SQL shop directly funds the development of free open source Firebird SQL.