How to repair a corrupt Firebird database?

Alexey Kovyazin, last update 28-March-2014
If Firebird database is corrupted, please follow these steps to fix it:

  1. Stop Firebird server (on Windows, it is usually running as a service, so open Control Panel, run applet Services and stop "Firebird Server - Default Instance") . Don't use the corrupted database - it leads to further corruption. Also, do not copy Firebird database when Firebird server is running - it leads to corrupted copy and, sometimes, to the corrupted original database.
  2. Make a copy of Firebird database file - usually, it is a single file with fdb or gdb extensions, and, when Firebird service is stopped, it is safe to copy database file with usual copy command or Windows Explorer. Always keep an original copy of the corrupted Firebird database for possible future use!
  3. Start Firebird server and run the following commands in command prompt, from Firebird\Bin folder (usually gfix and gbak tools are in Program Files\Firebird\Firebird_2_5\bin):
    gfix.exe -v -full -user SYSDBA -pass masterkey path_to_your_database
    gfix.exe -mend -ig -user SYSDBA -pass masterkey path_to_your_database
    gbak -b -g -v -user SYSDBA -pass masterkey path_to_your_database path_to_backup

    Try to run them all, even if gfix shows errors.
  4. If backup completed successfully, restore the database:
    gbak -c -v -user SYSDBA -pass masterkey path_to_backup path_to_database
  5. If gbak fails, download FirstAID Diagnostician, install it, and run Diagnose on the original corrupted database. See more details at FirstAID product page. Send full error text (or screenshot) and diagnostics log to IBSurgeon Support [email protected].

IBSurgeon's recovery tools

We offer FirstAID tool for automated database recovery, which (in combination with standard gfix and gbak) allows to fix up to 95% of the most prevalent Firebird and InterBase database corruptions.
If a full version of FirstAID will be unable to fix database corruption, we offer 2 hours of free recovery support to resolve this issue. 
For more information contact IBSurgeon's support: [email protected].