Search code examples
backupfirebirdrestore

Restoring Firebird 2.5 with fbsvcmgr


I'm configuring live backup and restore scripts to have "replicated" firebird dbs on main and reserve servers. Backup doing fine:

"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

Copying file to the remote server as well:

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

But restoring on remote side

"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 

caused an error:

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

The only way to restore database is to manually delete an old d:\reservedb\LABORATORY_DB.FDB before restoring. GBAK has the option to overwrite restorig db file, while fbsvcmgr seems to be not. Is there any other option? Did I miss something?


Solution

  • You can't restore over an existing database using nbackup. You either need to

    1. delete the old database first and then restore,
    2. or restore under a different name, delete the old database, and rename the new database to its final name.

    See also the nbackup documentation, chapter Making and restoring backups:

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

    As far as I know it was a design decision to not allow overwriting an existing database. Gbak indeed has that option, but only for historic reasons; if it were built today, it would likely not have that option.