如何备份/还原Firebird数据库? [英] How to backup/restore a Firebird database?

查看:381
本文介绍了如何备份/还原Firebird数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Firebird v2.5备份/还原过程感到非常困惑.我应该使用什么来备份/还原本地Firebird数据库: fbsvcmgr.exe gbak.exe isql.exe nbackup.exe

是所有这些选项,还是我在某些事情上错了!

对于C ++应用程序,实用的方法是什么?

我应该如何第一次知道数据库是否已经存在,所以我可以决定是否还原它.

解决方案

在firebird中创建备份的主要方法有两种:

  • gbak,它创建数据库的逻辑备份(对象描述"(例如表结构,视图等)和数据)
  • nbackup(也称为nbak),它创建数据库的物理备份(自上次nbackup以来物理数据页已更改)

在大多数情况下,我建议使用gbak,因为它更简单,并且还允许您在平台和Firebird版本之间移动备份,而nbackup仅真正适用于相同的平台和Firebird版本(但具有允许增量备份的优势).

ISQL是交互式查询CLI,不能用于创建备份. Fbsvcmgr是"Firebird服务管理器"工具,可用于在(远程)Firebird服务器上调用服务操作.这包括通过gbak和nbackup进行的备份和还原操作. Fbsvcmgr非常低级且难以使用(有关选项,请参见fbsvcmgr -?).

对于gbak,通常可以通过gbak可执行文件(选项-se[rvice] <service>)调用服务,另请参见 gbak-Firebird备份&还原实用程序.对于nbackup,请参见 Firebird的nbackup工具.

使用gbak备份时,通常会使用创建"(选项-c[reate])或重新创建"(-r[ecreate] o[verwrite]选项)还原数据库.如果数据库文件已经存在.有关更多信息,另请参见上面链接的gbak手册.

由于我不对C ++进行编程,因此我不会真正回答您有关如何从C ++应用程序执行此操作的问题,而您的问题已经太广泛了.但是请注意,可以从C ++代码调用Firebird服务操作,包括使用gbak和nbackup进行备份和还原(这实际上是Firebird工具本身所做的).如果您想进一步了解这一点,建议您在firebird-support邮件列表中询问.

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, gbak.exe, isql.exe or nbackup.exe

Are these all options or I am wrong about something!

What is the practical way to do it for a C++ application?

How should I know if a database already exists the first time, so I can decide whether to restore it or not.

解决方案

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.

这篇关于如何备份/还原Firebird数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆