Tuesday, July 1, 2008

Backup/Restore of Firebird Database

i using Firebird super server version 2.0

Backup Code :

FbBackupFile file = new FbBackupFile(@"C:\SAMPLEtestsample.fbk", 2048);
FbBackup backup = new FbBackup();
backup.BackupFiles.Add(file);
string connection = @"C:\SAMPLEDATABASE.FDB"
backup.ConnectionString = @"data source=pc205;initial catalog=" + connection + "User=SYSDBA; password=masterkey"
backup.ServiceOutput += new ServiceOutputEventHandler(backup_ServiceOutput);
backup.Options = FbBackupFlags.IgnoreLimbo;
backup.Execute();



Restore Code :

FbBackupFile restorefile = new FbBackupFile(@"C:\DATABASE.FBK", 2048);
FbRestore fbrestore = new FbRestore();
fbrestore.BackupFiles.Add(restorefile);

string connection = @"C:\DATABASE.FDB"
fbrestore.ConnectionString = @"data source=pc205;initial catalog=" + connection +"User=SYSDBA;password=masterkey"
fbrestore.PageSize = 2048;
fbrestore.Options = FbRestoreFlags.Create | FbRestoreFlags.Replace;
fbrestore.ServiceOutput += new ServiceOutputEventHandler(fbrestore_ServiceOutput);
fbrestore.Execute();