How to backup/restore a Firebird database?

前端 未结 2 1657
别那么骄傲
别那么骄傲 2020-12-12 06:46

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

相关标签:
2条回答
  • 2020-12-12 07:37

    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

    0 讨论(0)
  • 2020-12-12 07:40

    There are two primary ways to create backups in firebird:

    • gbak, which creates a logical backup of the database (object 'descriptions' (eg 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 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.

    0 讨论(0)
提交回复
热议问题