Task: try to repair a Firebird database (server running on Windows).
To solve this problem, we'll use the gfix and gbak utilities that come bundled with the Firebird server. Write a batch file (bat file) with the following contents inside:
@echo off
rem Prepare the database for repair
gfix.exe -mend -user SYSDBA -pas masterkey server:c:\db\mybase.gdb
rem Dump the database to another file
gbak.exe -b -g -user SYSDBA -pas masterkey server:c:\db\mybase.gdb c:\db\backup\mybase.bak
rem Save the original database file just in case - it is still the damaged file
rename c:\db\mybase.gdb c:\db\mybase.orig
rem Now restore the database
gbak.exe -user SYSDBA -pas masterkey C:\db\backup\mybase.bak server:c:\db\mybase.gdb
Here:
-pas masterkey - the root password
C:\db\mybase.gdb - this is our damaged database
C:\db\backup - the folder where you can put database backups (make sure the backup being created doesn't overwrite a working backup, if one exists!)
If the damage isn't serious, this operation will check for glitches and bring the database back to life.
Applies to: Windows + Firebird
Comments