Today, one guy I know called and asked if I can help him with accounting system in his restaurant. There was cryptic message from accounting software with some sort of DB error.
I saw system like this first time in my life so I started to investigate DB backend and I found Firebird / InterBase. Actually I saw Firebird in production for first time in my life. I started to think about fixing database from command line and i googled a lot ’till found solution. I should verify DB, prepare for dump and then restore.
This is how I achieved task:
1. disconnect users – in my case accounting software;
2. create backup copy of database file;
3. run gfix to validate database;
gfix -v dbname
4. I prefer full validation;
gfix -v -f dbname
5. prepare corrupted database for backup;
gfix -mend dbname
6. backup database – -g switch disables garbage collection;
gbak -g -b dbname.backup
7. restore database -r replaces existing database (remember that part about copy?);
gbak -v -c -r dbname.backup dbname
If you are lucky enough you have now working database. I wasn’t. During restore there was problem with primary key on one of the tables. I “fixed” (i mean – it worked for me) it running this:
gbak -v -c -r -i dbname.backup dbname
-i switch creates indexes as inactive which worked for me.
People were happy today and my introduction to Firebird was only one hour long. ;)