Setting Up a Backup Component
Go Up to Backing Up Databases
To set up a simple backup component:
- 1. Drop a
TIBBackupServicecomponent on a Delphi form. - 2. Drop
ButtonandMemocomponents on the form. - 3. Enter the name and path of the database to be backed up in the
DatabaseNamefield and the name and path of the database backup file in theBackupFilestring 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
ServiceStartmethod.
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;