I am really confused here about Firebird v2.5 backup/restore process. What should I use to backup/restore a local Firebird database: fbsvcmgr.exe, g
I usually use gbak (don't know about the others).
Backup
gbak -b -v -user SYSDBA -password "masterkey" D:\database.FDB E:\database.fbk
Restore
gbak -c -user SYSDBA -password masterkey E:\database.fbk E:\database_restore.fdb
If file exists for restore you could do it with gbak restore flags -c = create new file -r = replace file
Here is good page for FB backup/restore: http://www.destructor.de/firebird/gbak.htm
There are two primary ways to create backups in firebird:
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 a 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 wont 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 mailing list.