Setting Up a Backup Component

From InterBase
Jump to: navigation, search

To set up a simple backup component:

1. Drop a TIBBackupService component on a Delphi form.
2. Drop Button and Memo components on the form.
3. Enter the name and path of the database to be backed up in the DatabaseName field and the name and path of the database backup file in the BackupFile string field of the Object Inspector, or double click on the button and set the properties in code:
procedure TForm1.Button1Click(Sender: TObject);
begin
with IBBackupService1 do
  begin
   DatabaseName := 'employee.gdb';
  BackupFile.Add('d:\temp\employee1.gbk');
    end;
end;
4. Attach to the service manager as described in Attaching to a Service Manager, or set the properties in code:
with IBBackupService1 do
begin
  ServerName := 'Poulet';
  LoginPrompt := False;
  Params.Add('user_name=sysdba');
  Params.Add('password=masterkey');
  Active := True;
   end;
5. Set any other options in the Object inspector (or set them in code), and then start the service with the ServiceStart method.

The final code for a backup application that displays verbose backup output in a Memo component might look like this:

procedure TForm1.Button1Click(Sender: TObject);
begin
with IBBackupService1 do
begin
ServerName := 'Poulet';
LoginPrompt := False;
Params.Add('user_name=sysdba');
Params.Add('password=masterkey');
Active := True;
try
verbose := True;
Options := [NonTransportable, IgnoreLimbo];
DatabaseName := 'employee.gdb';
BackupFile.Add('d:\temp\employee1.gbk');
ServiceStart;
While not Eof do
Memo1.Lines.Add(GetNextLine);
finally
Active := False;
end;
end;
end;