firebirddatabase-backupsfirebird2.5

How to check backup integrity


We are using Firebird 2.5.* and we use the gbak.exe command to back up and restore the databases.

A case of backup restoration occurred, where the user selected an incorrect file to restore from the backup (an XML file, for example) - an error occurred in gbak, but it corrupted the database.

I didn't find in the Firebird/gbak documentation a parameter to check the integrity of the backup (without performing the restore).

I would like to know if there is any way to check if the Firebird backup file "is valid", without actually restoring the backup. Use the gbak.exe command to check the integrity of the backup, without having to restore.

This way we can validate that the backup file is valid, before proceeding with the restoration.


Solution

  • There is no way to verify the validity of a backup, other than restoring. However, the scenario you describe suggests that you used the -recreate_database overwrite (or -r o for short) or -replace_database or (-rep) option, instead of the -create_database (or -c) or -recreate_database (without overwrite; or -r) options. These last two options will fail if a database already exists under the name. The first two options will first drop/delete the existing database and only then restore it.

    The scenario you were confronted with is explicitly mentioned in Restore Or Recreate section of the Firebird Backup & Restore Utility manual:

    Finally, if the restore process discovers that the dump file is corrupt, the restore will fail and your previously working database will be gone forever.

    (In this context, a file which is not a gbak backup file is indistinguishable from a corrupt backup.)

    The recommended procedure is to restore to a different filename, and then rename it to the right filename after the restore completed successfully.