Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

Before use FbRestore need to call FbConnection.ClearAllPools()

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top