Hi all...
We have an c# .net forms application that we are trying to provide firebird 2.0.1 embedded database backup functionality built in. Under the covers, we have tried using a gbak by using the following code:
Code:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
if (System.IO.File.Exists("gbak.exe"))
{
string args = string.Format("-v -t -user {0} -password {1} \"{2}\" \"{3}\"",
DB_USER,
DB_PASSWORD,
source,
destination);
proc.StartInfo.FileName = "gbak.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Arguments = args;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = true;
try
{
proc.Start();
proc.WaitForExit();
string foo = proc.StandardOutput.ReadToEnd();
string bar = proc.StandardError.ReadToEnd();
Console.WriteLine(foo);
Console.WriteLine(bar);
Console.WriteLine(args);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
but we are seeing that the database is locked and we get the error:
gbak: ERROR:I/O error for file "C:\DEV\HOSTSIDE\DOTNET\PLUSIDMANAGER\PRIVARIS.PLUSIDMANAGER\BIN\RELEASE\PLUSID.FDB"
gbak: ERROR: Error while trying to open file
gbak: ERROR: The process cannot access the file because it is being used by another process.
The lock is being held by our own application. We have also tried doing the same with...
Code:
FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
cs.UserID = "SYSDBA";
cs.Password = "masterkey";
cs.Database = source;
FbBackup backupSvc = new FbBackup();
backupSvc.ConnectionString = cs.ToString();
backupSvc.BackupFiles.Add(new FbBackupFile(destination, 2048));
backupSvc.Verbose = true;
backupSvc.Options = FbBackupFlags.IgnoreLimbo | FbBackupFlags.NoGarbageCollect;
backupSvc.ServiceOutput += new ServiceOutputEventHandler(backupSvc_ServiceOutput);
try
{
backupSvc.Execute();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
This fails for the same reason as using the gbak method. Here are some questions I have:
1. Since embedded mode creates 'an exclusive lock' is it then true that we would not be able to create backups with gbak while the database is running?
2. Will creating backups be possible with super server mode while the app is running?
3. What other options might we have to backup the embedded database while the app is running?
Thanks!
Isz