使用 fbsvcmgr 恢复 Firebird 2.5

Restoring Firebird 2.5 with fbsvcmgr

我正在配置实时备份和还原脚本,以便在主服务器和备用服务器上安装 "replicated" firebird 数据库。 备份正常:

"C:\Program Files\Firebird\Firebird_2_5\bin\nbackup" -B 0 "D:\testdb\LABORATORY_DB.FDB" D:\testdb\lab_FULL.fbk -user SYSDBA -pass masterkey -D OFF

同时将文件复制到远程服务器:

net use R: \fbserv2\reserve
xcopy /Y D:\testdb\lab_FULL.fbk R:\ 

但在远端恢复

"C:\Program Files\Firebird\Firebird_2_5\bin\fbsvcmgr.exe" fbserv2:service_mgr -user SYSDBA -password masterkey -action_nrest -dbname d:\reservedb\LABORATORY_DB.FDB -nbk_file d:\reserve\lab_FULL.fbk 

导致错误:

Error (80) creating database file: d:\reservedb\LABORATORY_DB.FDB via copying from: d:\reserve\lab_FULL.fbk

恢复数据库的唯一方法是在恢复之前手动删除旧的 d:\reservedb\LABORATORY_DB.FDB。 GBAK 有覆盖 restorig db 文件的选项,而 fbsvcmgr 似乎没有。还有其他选择吗?我错过了什么吗?

您无法使用 nbackup 恢复现有数据库。你要么需要

  1. 先删除旧数据库再恢复,
  2. 或以不同的名称恢复,删除旧数据库,并将新数据库重命名为其最终名称。

另请参阅 nbackup 文档,第 Making and restoring backups 章:

If the specified database file already exists, the restore fails and you get an error message.

据我所知,不允许覆盖现有数据库是一项设计决定。 Gbak 确实有这个选项,但只是出于历史原因;如果它是今天建造的,它可能没有那个选项。