문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

Before use FbRestore need to call FbConnection.ClearAllPools()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top