"how to backup/restore a firebird database?" Code Answer


there are two primary ways to create backups in firebird:

  • gbak, which creates a logical backup of the database (object 'descriptions' (e.g. table structure, views, etc) and data)
  • nbackup (also known as nbak), which creates a physical backup of the database (physical data pages changed since the previous nbackup)

in most cases, i'd suggest to use gbak, because it is simpler and also allows you to move backups between platforms and firebird versions, while nbackup is only really suitable for the same platform and firebird version (but has the advantage of allowing incremental backups).

isql is an interactive query cli, and cannot be used to create backups. fbsvcmgr is the "firebird service manager" tool, which can be used to invoke service operations on a (remote) firebird server. this includes backup and restore operations through gbak and nbackup. fbsvcmgr is pretty low-level and hard to use (see fbsvcmgr -? for options).

for gbak, you'd normally invoke the services through the gbak executable (option -se[rvice] <service>), see also remote backups & restores in the gbak documentation. for nbackup you either can use the nbackup tool locally, or you need to use the fbsvcmgr (or another tool that supports service operations) to invoke the same functionality remotely (action_nbak and action_nrest), see also backups on remote machines (firebird 2.5+) in the nbackup documentation.

for detailed description on gbak, see gbak - firebird backup & restore utility. for nbackup, see firebird's nbackup tool.

with a gbak backup, you'd normally restore the database using 'create' (option -c[reate]) or 'recreate' (-r[ecreate] without o[verwrite] option), which will fail if the database file already exists. see also the gbak manual linked above for more information.

i won't really answer your question about how to do it from a c++ application, because i don't program c++, and your question is already too broad as it is. but know that it is possible to invoke firebird service operations, including backup and restore using both gbak and nbackup, from c++ code (that is essentially what firebird tools itself do). if you want to know more about that, i'd suggest you ask on the firebird-support google group.

By HRoll on May 19 2022

Answers related to “how to backup/restore a firebird database?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.