Setting up a Restore Component
Go Up to Restoring Databases
To set up a simple restore component:
- Drop a
TIBRestoreServicecomponent on a Delphi form. - Drop
ButtonandMemocomponents on the form. - Enter the name and path of the database to be restored 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 IBRestoreService1 do begin DatabaseName.Add('employee.gdb'); BackupFile.Add('c:\temp\employee1.gbk'); end; - 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; - Set any other options in the Object inspector (or set them in code), and then start the restore service with the
ServiceStartmethod. The final code for a restore application that displays verbose restore output in aMemocomponent 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;