Use TIBCRestoreService to restore backup on remote server

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
dchavez
Posts: 2
Joined: Thu 28 Feb 2019 17:21

Use TIBCRestoreService to restore backup on remote server

Post by dchavez » Thu 28 Feb 2019 17:30

Currently I am able to restore a Firebird backup when my client is connected to a Firebird service that is running on the same pc, using the following code:

with IBCRestoreService1 do
begin
ClientLibrary := 'fbclient.dll';
Protocol := TCP;
Server := '';
Params.Add('user_name=SYSDBA');
Params.Add('password=masterkey');
LoginPrompt := False;
Attach;
Options := Options + [roCreateNewDB];
Verbose := True; // False;
Database.Clear;
Database.Add('c:\db\new.fdb');
BackupFile.Clear;
BackupFile.Add('c:\db\backup1.fbk');
ServiceStart;
end; // with

Is it possible to do restore a backup that resides on a remote server? The backup would reside on the remote server and the database would also be restored on the remote server. How should I configure the TIBCRestoreService to do this?

Thanks,

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Use TIBCRestoreService to restore backup on remote server

Post by ViktorV » Fri 01 Mar 2019 09:33

Yes, you can use TIBCRestoreService to restore the backup on the remote server. To do this, you need to set the TIBCRestoreService.Server property to the value of the corresponding IP address or host name of the remote Firebird server.
Please note that the directories for the restored database and the directory to the backup file are the local directories on the machine where Firebird is running.

You can use the following code demonstrating the work with TIBCBackupService and TIBCRestoreService by presetting the correct values instead of (Server, Port, NewDatabase, ClientLibrary, BackupFile):

Code: Select all

program Project;
{$APPTYPE CONSOLE}

uses
  System.SysUtils, IBCAdmin;

var
  IBCBackupService: TIBCBackupService;
  IBCRestoreService: TIBCRestoreService;

begin
  IBCBackupService := TIBCBackupService.Create(nil);
    try
      IBCBackupService.Server := Server; //FB server
      IBCBackupService.Port := Port; //FB port
      IBCBackupService.Username := Username;
      IBCBackupService.Password := Password;
      IBCBackupService.ClientLibrary := ClientLibrary; //FB client library
      IBCBackupService.BackupFile.Text :=  BackupFile;
      IBCBackupService.Database := DataBase;
      IBCBackupService.Verbose := True;
      IBCBackupService.Active := True;
      IBCBackupService.ServiceStart;
      while not IBCBackupService.Eof do
        IBCBackupService.GetNextLine;
      WriteLn('Backup Ok');
    finally
      IBCBackupService.Active := False;
      IBCBackupService.Free;
    end;

  IBCRestoreService := TIBCRestoreService.Create(nil);
    try
      IBCRestoreService.Server := Server; //FB server
      IBCRestoreService.Port := Port; //FB port
      IBCRestoreService.Username := Username;
      IBCRestoreService.Password := Password;
      IBCRestoreService.ClientLibrary := ClientLibrary; //FB client library
      IBCRestoreService.BackupFile.Text :=  BackupFile;
      IBCRestoreService.Database.Text := DataBase;
      IBCRestoreService.Options := IBCRestoreService.Options + [roReplace];
      IBCRestoreService.Verbose := True;
      IBCRestoreService.Active := True;
      IBCRestoreService.ServiceStart;
      while not IBCRestoreService.Eof do
        IBCRestoreService.GetNextLine;
      WriteLn('Restore Ok');
    finally
      IBCRestoreService.Active := False;
      IBCRestoreService.Free;
    end;

  ReadLn;

end.

Post Reply