<< Database configuration | Firebird SQL Server 2.x Administration Handbook | Links, literature >>


Firebird database backups should be performed for the following reasons:

  • The database file (.fdb file) should not be backed up directly as a file, as it is not compatible with other platforms and Firebird/InterBase® versions.
  • Moreover the .fdb file is in an instable condition if one or more users are connected to the database (open edit access etc.). This is also an argument against backing up the database file at file level.
  • No empty page areas or indices need to be stored in the backup. The backup file is therefore (usually much) smaller.
  • Databases can also be repaired or reduced in size by performing a backup and restore.
  • If a database needs to be ported to another platform (e.g. from a Windows server to a Linux server), it is not the database file that is ported but the backup. This is then imported to the destination server by performing a restore of the backup file.

A backup generates a backup file. This has its own file format and contains a consistent data view, because the backup extract the data as an independent transaction.

A backup can be carried out during runtime. During this time database performance may degrade, particularly if the backup runs for some time.

The usual suffix for backup files is: .fbk

Backup in productive environments

Productive systems should be backed up regularly. The .fdb backup file can be backed up using conventional file backup methods.

If the server runs through the night, the backup can be started by a scheduler (Windows: AT service, Linux: cron).


The AT command can be used to issue tasks to a Winedows NT server (NT4, 2000, XP, 2003), which should be performed at a certain specified time.

Example: A database should be backed up nightly at 4 am. Enter the following command in the Windows prompt:

 at 04:00 /every:mo,di,mi,do,fr,sa,so /interactive

 -> c:\Programme\Firebird\bin\gbak -t -user SYSDBA -password masterkey
 -> harry:c:\DB\pmm.fdb k:\Backups\pmm.fbk

Tip: Do not run such tasks nightly between 02:00 and 03:00. When clocks are put forward to summer time in the Spring this hour does not exist at all, when changing back in the Fall, this hour occurs twice.

See also:
Backup Database
Firebird Administration

back to top of page

gbak utility

Backup and restore are executed by Firebird using the gbak utility. The gbak utility may be installed on any computer, even on the database server itself. It can be found in the Firebird bin directory.

gbak is a command-line tool, which means it can be easily called from batch files, shell scripts or scheduler services.

General syntax

 gbak <optionen> -user <benutzer> -password <passwort> <quelle> <ziel>

The most important general options:

–bBackup (default; does not need to be specified explicitly).
–cRestore (Create).
–rReplace: an existing database is overwritten by the restore.
–user <benutzername>Specification of the user name.
–password <passwort>Specification of the password.
–vVerbose: detailed log of the action currently being conducted.
–y <dateiname>Exports all log messages into the specified file. The file may not already exist at the time gbak starts!
–y suppress_outputNo log output.
–zDisplay the gbak version number.

See also:

back to top of page


The database must be named as source and the backup file named as the target. The target must be a filename in the computer file system which is executing gbak. If no directory is explicitly named, the current directory is used.

A backup may only be performed by the SYSDBA or the database owner.


–tTransportable Backup: A backup is generated, which can be read by all Firebird/InterBase® database, independent of version and platform.
Recommended for all backups.
–gPrevents garbage collection being performed during the backup.
–ignoreChecksum errors are ignored during the backup.
–mMetadata only: Only the metadata are backed up, not the table contents.
–ntNon-transportable format: The opposite of –t. Not recommended.
–se <hostname>:service_mgrUses the Service Manager.
Backup: the backup file is created on the database server.
Restore: the restore is made from a file which is on the database server.
This option must be specified if the security2.fdb is to be backed up.

Typical backup example

 gbak -v -t -user SYSDBA -password masterkey dbserver:pmm c:\Backup\pmm.fbk
–vVerbose output.
–tTransportable format.
–user SYSDBAUser name.
–password masterkeyPassword (the password can be entered in quotes if it contains empty spaces).
dbserver:pmmDatabase name (pmm is obviously an alias registered on dbserver).

Another example:

 gbak -v -t -user SYSDBA -password masterkey joe:/db/pmm.fdb c:\backup.fbk

Metadata backup

 gbak -v -t -m -user SYSDBA -password masterkey dbserver:pmm c:\backup.fbk

See also:
Backup Database

back to top of page


A restore converts a backup file into a database. The source is the backup file (.fbk file) and the target is the database name. It is possible to overwrite an existing database.


–cRestore in a new database. I.e. the database file of the new database MUST NOT exist, otherwise the restore is aborted and an error message appears. Mutually exclusive with –rep.
–repReplaces an existing database. This database may not be in use at the time of the restore! It can only be performed by the SYSDBA or the database owner. Mutually exclusive with –c.
–iSets all indices to inactive when restoring. The restore is quicker and indices can be activated singly or together, and recomputed by the activation.
–nRemoves all validity constraints from the metadata. This enables data to be restored which violates these constraints and otherwise could not be restored.
–oRestores one table at a time. This can be uses to partially restore databases with corrupt table data.
–p <bytes>Sets a different page size for the new database. The page size must be a multiple of 1024. Values > 16984 cannot be used, values < 4096 are not recommended (and not allowed in Firebird 2.1).
–use_all_spaceFills all database pages to 100% instead of the usual 80%.

Typical restore example

 gbak -c -v -user SYSDBA -password masterkey c:\backup\pmm.fbk dbserver:pmm

Restore to an existing database

 gbak -rep -v -user SYSDBA -password masterkey c:\backups\pmm.fbk

See also:
Restore Database

back to top of page

User database security2.fdb

All Firebird service users are stored in the user database, security2.fdb in the Firebird root directory. For a complete data backup a backup of this database should also be made. gbak can be used for this.

The security database can however not be backed up remotely. The Service Manager has to be used. The backup file is generated physically on the database server. If it is created in a released directory, it can then be moved to another location.

For security reasons the security database and any backups of it should not be accessible to non-administrators.

A direct backup of the security2.fdb is however possible, as the Firebird service always has it open. So should you ever need to recover the security2.fdb you will need to follow the following procedure:

  • You need a functional user database, so that the service can run. If necessary carry out a new installation. (Here the SYSDBA user is already set up with a password that is known.)
  • Perform a restore using gbak, however not directly overwriting the existing security2.fdb in the Firebird root directory, but somewhere else.
  • Shut down the Firebird service. In Windows using the Services Manager, in Linux with the fbmgr utility.
  • Replace the security2.fdb in the Firebird root directory with the file just created by the restore.
  • Restart the Firebird service.

See also:
Security in Firebird 2

back to top of page
<< Database configuration | Firebird SQL Server 2.x Administration Handbook | Links, literature >>