Pergunta

I have database backup which I want to restore to database, but when I run example code:

FbRestore restoreSvc = new FbRestore();
restoreSvc.ConnectionString = "...";
restoreSvc.BackupFiles.Add(new FbBackupFile(dumpFileName, 2048));
restoreSvc.PageSize = 4096;
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
restoreSvc.Execute();

it ends throwing exception

could not drop database ...db path... (database might be in use)
   at FirebirdSql.Data.Services.FbRestore.Execute()

By default there are other applications using the database, but if I stop all of them, nothing is changed.

How can I restore database in such environment?

Foi útil?

Solução

You need to ensure that the database can be dropped. That means nobody is currently using it.

If it's only your application you should close all connections (really close, be aware of connection pooling) and then do the restore. Or if there are also other connections you can i.e. forcibly close these connections by doing DELETE FROM MON$ATTACHMENTS WHERE MON$ATTACHMENT_ID <> CURRENT_CONNECTION.

Outras dicas

Before use FbRestore need to call FbConnection.ClearAllPools()

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top