Skip to main content
Database Corruption Handling
Updated today

When a database stops functioning correctly it usually means there is some form of error in one of the tables of the database. These corruptions usually present themselves as; HowNow not opening, certain tabs not loading correctly or particular functions causing a lockup.

The first step when you think a database might have a corruption is to perform a backup and restore. In some cases this can fix the corruption as it pushes all data into a new database, however in some rare cases a backup of the database will show a "Internal gds software consistency check" error. This error indicates that database repairs are required before a successful backup can be run.

For details descriptions of all available repairs and parameters please see the Firebird documentation or the destructor website

Basic steps to repair a HowNow database corruption

1. Database Shutdown

If there is maintenance work required on a database, you may wish to close down that database under certain circumstances. When a database has been shut down, only SYSDBA and the database owner are able to connect to the database in order to perform administrative tasks and only allows a single connection.

The below command will shut the database down straight away.

Command:

gfix -shut full -attach 0 -user SYSDBA -password masterkey dbserver:/db/mydb.fdb

2. Database Validation

Sometimes, databases get corrupted. Under certain circumstances, you are advised to validate the database to check for corruption. The times you would check are:

  • When an application receives a database corrupt error message.

  • When a backup fails to complete without errors.

  • If an application aborts rather than shutting down cleanly.

  • On demand - when the SYSDBA decides to check the database.

The below command will do a FULL validation whilst ignoring both check-some errors and limb transactions.

Command:

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -v -full

3. Database Recovery

If the database validation described above produces no output then the database structures can be assumed to be valid. However, in the event that errors are reported, you may have to repair the database before it can be used again

The below command will mend the database corruptions and repair the database for a subsequent backup.

Command:

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -me

4. Database Backup

Once the database has been validated and mended it's time to do a backup of the database.

The below command will do a verbose backup on the database whilst again ignoring both check-some errors and limb transactions.

Command:

gbak -user <username> -password <password> <server:source> <destination> -b -v -ig -l

4. Database Restore

Once the database backup has been successful its time to restore it to a new database file.

The below command will do a verbose restore the database.

Command:

gbak -user <username> -password <password> <source> <destination> -c -v
Did this answer your question?