unit unitRestaurar;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Mask, ToolEdit, ExtCtrls, IBServices;

type
  TfrmRestaurar = class(TForm)
    IBRestoreService1: TIBRestoreService;
    Panel1: TPanel;
    feRestaurar: TFilenameEdit;
    feRestBanco: TFilenameEdit;
    Label1: TLabel;
    Label2: TLabel;
    btnRestaurar: TBitBtn;
    procedure btnRestaurarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmRestaurar: TfrmRestaurar;

implementation

{$R *.dfm}

procedure TfrmRestaurar.btnRestaurarClick(Sender: TObject);
begin
if feRestaurar.FileName = '' then
 begin
    Showmessage('Indique onde esta o seu Arquivo de Backup');
    feRestaurar.SetFocus;
    Abort;
 end;
 if feRestBanco.Text = '' then
 begin
    Showmessage('Indique onde irá Restaurar o seu Backup ');
    feRestBanco.SetFocus;
    Abort;
 end;
 with IBRestoreService1 do
  begin
    Params.Clear;
    BackupFile.Clear;
    ServerName := 'localhost';
    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(feRestBanco.FileName);
      BackupFile.Add(feRestaurar.FileName);
      ServiceStart;
    finally
      Active := False;
    end;
  end;
  Showmessage('Restauração Efetuada com Sucesso');
end;

end.
