Setting up a Restore Component

From InterBase
Jump to: navigation, search

Go Up to Restoring Databases


To set up a simple restore component:

  1. Drop a TIBRestoreService 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 restored 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 IBRestoreService1 do
    begin
     DatabaseName.Add('employee.gdb');
     BackupFile.Add('c:\temp\employee1.gbk');
       end;
    
  4. Attach to the service manager as described in Attaching to a Service Manager, or set the properties in code:
    begin
    with IBRestoreService1 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 restore service with the ServiceStart method. The final code for a restore application that displays verbose restore output in a Memo component might look like this:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with IBRestoreService1 do
    begin
    ServerName := 'Poulet';
    LoginPrompt := False;
    Params.Add('user_name=sysdba');
    Params.Add('password=masterkey');
    Active := True;
    try
    Verbose := True;
    Options := [Replace, UseAllSpace];
    PageBuffers := 3000;
    PageSize := 4096;
    DatabaseName.Add('c:\InterBase6\tutorial\tutorial.ib');
          BackupFile.Add('c:\InterBase6\tutorial\backups\tutor5.gbk');
          ServiceStart;
    While not Eof do
    Memo1.Lines.Add(GetNextLine);
    finally
    Active := False;
    end;
    end;
    end;