Question

I have a Windows 7 application, running in VirtualBox VM. It used to restore the database when running natively using System.Diagnostics.Process, but stopped a few months ago. This is my code:

Cursor.Current = Cursors.WaitCursor;
bookConn.Close();  //  close the connection

FbRestore restoreSvc = new FbRestore();
restoreSvc.ConnectionString = "User=SYSDBA;Password=masterkey;DataSource=localhost;Database=" + dbPath + ";Pooling=true;";
restoreSvc.BackupFiles.Add(new FbBackupFile(backupFilename, 2048));
restoreSvc.PageSize = 4096;
restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
restoreSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);
restoreSvc.Execute();

Cursor.Current = Cursors.Default;

I can restore from the command line, but not from within the Windows application. Any ideas why not?

Was it helpful?

Solution

Expanding on my comment here are a few things to try:

First, to try and get some logging going and I recall reading somewhere about a "known" bug where you sometimes need to force verbose=true please try with this code snippet:

public void RestoreDatabase(string dbPath)
{
    FbRestore restoreSvc = new FbRestore();

    restoreSvc.ConnectionString = "User=SYSDBA;Password=masterkey;DataSource=localhost;Database=" + dbPath + ";Pooling=true;";
    restoreSvc.BackupFiles.Add(new FbBackupFile(BackupRestoreFile, 2048));
    restoreSvc.Verbose = true; // Enable verbose logging
    restoreSvc.PageSize = 4096;
    restoreSvc.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;

    restoreSvc.ServiceOutput += new ServiceOutputEventHandler(ServiceOutput);

    restoreSvc.Execute();
}

private void ServiceOutput(object sender, ServiceOutputEventArgs e)
{
    Console.WriteLine(e.Message);
}

This should then hopefully shed some light on what is happening as you should start to get some logging. Execute MAY terminate immediately though so you need to ensure that your app doesn't end while the backup is still restoring and writing to the ServiceOutput etc.

It would also be worth checking that when you run your application you are running as an administrator to ensure there are no strange Windows permission issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top