Subject | RE: [IBO] Backup Components |
---|---|
Author | Dmitry A. Beloshistov |
Post date | 2014-06-25T06:20:44Z |
Hi..
Try this:
Function SAPIDataBaseBackup(IB_Connection:TIB_Connection; BackupFiles:TStrings;
BackupOptions:TBackupOptions; Log:TStrings=nil):boolean;
var IBBS:TIBOBackupService;
begin
if not Assigned(IB_Connection) then
raise Exception.Create(EXBDS_NOIBCONNECTION);
Result:=True;
IBBS:=TIBOBackupService.Create(IB_Connection);
try
IBBS.DatabaseName:=IB_Connection.Database;
if not Assigned(BackupFiles) or (BackupFiles.Count=0) then
begin
IBBS.BackupFile.Clear;
IBBS.BackupFile.Add(ChangeFileExt(IB_Connection.Database,'.gbk')+'=2048');
end
else IBBS.BackupFile.Assign(BackupFiles);
IBBS.Options:=BackupOptions;
IBBS.Params.Add('user_name='+IB_Connection.Username);
IBBS.Params.Add('password='+IB_Connection.Password);
IBBS.ServerName:=IB_Connection.Server;
IBBS.Protocol:=IB_Connection.Protocol;
IBBS.Verbose:=Assigned(Log);
with IBBS do
begin
LoginPrompt:=False;
try
Active:=True;
try
ServiceStart;
if Verbose then while not EOF do Log.Add(GetNextLine);
except on E:Exception do Result:=False;
end;
finally Active := False; end;
end;
finally IBBS.Free; end;
end;
Function SAPIDatabaseRestore(ServerName,UserName,Password:string;
Protocol:TIB_Protocol;
DatabaseFiles,BackupFiles:TStrings;
PageSize:integer; RestoreOptions:TRestoreOptions;
Log:TStrings=nil):boolean;
var IBRS:TIBORestoreService;
begin
if not Assigned(DatabaseFiles) or (DatabaseFiles.Count=0) then
raise Exception.Create('Missing database name for restore!');
if not Assigned(BackupFiles) or (BackupFiles.Count=0) then
raise Exception.Create('Missing backup file(s) for restore!');
Result:=True;
IBRS:=TIBORestoreService.Create(nil);
try
IBRS.Params.Add('user_name='+UserName);
IBRS.Params.Add('password='+Password);
IBRS.DatabaseName.Assign(DatabaseFiles);
IBRS.BackupFile.Assign(BackupFiles);
IBRS.PageSize:=PageSize;
IBRS.Options:=RestoreOptions;
IBRS.ServerName:=ServerName; //13.05.2005
IBRS.Protocol:=Protocol; //13.05.2005
IBRS.Verbose:=Assigned(Log);
with IBRS do
begin
LoginPrompt:=False;
try
Active:=True;
try
ServiceStart;
if Verbose then while not EOF do Log.Add(GetNextLine);
except on E:Exception do Result:=False;
end;
finally Active := False; end;
end;
finally IBRS.Free; end;
end;
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Tuesday, June 24, 2014 3:53 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Backup Components
Hello
I need example for the TIBOBackupService and TIBONBackupService Components.
Thank you for regards.
Fabian Kruszelnicki
[Non-text portions of this message have been removed]
Try this:
Function SAPIDataBaseBackup(IB_Connection:TIB_Connection; BackupFiles:TStrings;
BackupOptions:TBackupOptions; Log:TStrings=nil):boolean;
var IBBS:TIBOBackupService;
begin
if not Assigned(IB_Connection) then
raise Exception.Create(EXBDS_NOIBCONNECTION);
Result:=True;
IBBS:=TIBOBackupService.Create(IB_Connection);
try
IBBS.DatabaseName:=IB_Connection.Database;
if not Assigned(BackupFiles) or (BackupFiles.Count=0) then
begin
IBBS.BackupFile.Clear;
IBBS.BackupFile.Add(ChangeFileExt(IB_Connection.Database,'.gbk')+'=2048');
end
else IBBS.BackupFile.Assign(BackupFiles);
IBBS.Options:=BackupOptions;
IBBS.Params.Add('user_name='+IB_Connection.Username);
IBBS.Params.Add('password='+IB_Connection.Password);
IBBS.ServerName:=IB_Connection.Server;
IBBS.Protocol:=IB_Connection.Protocol;
IBBS.Verbose:=Assigned(Log);
with IBBS do
begin
LoginPrompt:=False;
try
Active:=True;
try
ServiceStart;
if Verbose then while not EOF do Log.Add(GetNextLine);
except on E:Exception do Result:=False;
end;
finally Active := False; end;
end;
finally IBBS.Free; end;
end;
Function SAPIDatabaseRestore(ServerName,UserName,Password:string;
Protocol:TIB_Protocol;
DatabaseFiles,BackupFiles:TStrings;
PageSize:integer; RestoreOptions:TRestoreOptions;
Log:TStrings=nil):boolean;
var IBRS:TIBORestoreService;
begin
if not Assigned(DatabaseFiles) or (DatabaseFiles.Count=0) then
raise Exception.Create('Missing database name for restore!');
if not Assigned(BackupFiles) or (BackupFiles.Count=0) then
raise Exception.Create('Missing backup file(s) for restore!');
Result:=True;
IBRS:=TIBORestoreService.Create(nil);
try
IBRS.Params.Add('user_name='+UserName);
IBRS.Params.Add('password='+Password);
IBRS.DatabaseName.Assign(DatabaseFiles);
IBRS.BackupFile.Assign(BackupFiles);
IBRS.PageSize:=PageSize;
IBRS.Options:=RestoreOptions;
IBRS.ServerName:=ServerName; //13.05.2005
IBRS.Protocol:=Protocol; //13.05.2005
IBRS.Verbose:=Assigned(Log);
with IBRS do
begin
LoginPrompt:=False;
try
Active:=True;
try
ServiceStart;
if Verbose then while not EOF do Log.Add(GetNextLine);
except on E:Exception do Result:=False;
end;
finally Active := False; end;
end;
finally IBRS.Free; end;
end;
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Tuesday, June 24, 2014 3:53 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Backup Components
Hello
I need example for the TIBOBackupService and TIBONBackupService Components.
Thank you for regards.
Fabian Kruszelnicki
[Non-text portions of this message have been removed]