How to Backup Db on Remote Host to local drive

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sugi
Posts: 43
Joined: Wed 07 Dec 2016 02:05

How to Backup Db on Remote Host to local drive

Post by sugi » Wed 30 May 2018 08:50

Hi guys,

How to backup firebird database on remote host into local drive?

I use this code, but no avail

Code: Select all

   Backup->BackupFile->Add("h:\\b1.fbk");
   Backup->Server        = "localhost/3900";
   Backup->Attach();
   Backup->ServiceStart();
   ShowMessage("Finished.");
The Server (localhost/3900) is also used by TIBCConnection and runs OK.
App runs without an error, but no backup file created.

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

Re: How to Backup Db on Remote Host to local drive

Post by ViktorV » Wed 30 May 2018 14:12

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;
      IBCBackupService.Port := Port;
      IBCBackupService.Username := Username;
      IBCBackupService.Password := Password;
      IBCBackupService.ClientLibrary := ClientLibrary;
      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;
      IBCRestoreService.Port := Port;
      IBCRestoreService.Username := Username;
      IBCRestoreService.Password := Password;
      IBCRestoreService.ClientLibrary := ClientLibrary;
      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.

sugi
Posts: 43
Joined: Wed 07 Dec 2016 02:05

Re: How to Backup Db on Remote Host to local drive

Post by sugi » Thu 31 May 2018 01:45

Hello,

The others values that was not in my codes was set on TIBCBackupService properties.

I tried again with these codes

Code: Select all

   Backup->BackupFile->Add("h:\\b1.fbk");
   Backup->Server = "localhost/3900";
   Backup->Active = true;
   Backup->ServiceStart();

   int i = 0;
   while(!Backup->Eof)
   {
      i++;
      Lbl->Caption = AnsiString(i);
      Application->ProcessMessages();
      Backup->GetNextLine();
   }
   ShowMessage("Finished");
It worked OK BUT backup file created on remote host. There was a file name h:\b1.fbk on my remote host server.

Is it possible that backup file created on my local drive, not on remote host?

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

Re: How to Backup Db on Remote Host to local drive

Post by ViktorV » Thu 31 May 2018 08:22

When executing backup on the remote machine, the resulting file is created on the remote machine. This is the specific behavior of Firebird, not IBDAC, and we cannot influence it in any way.
You can get more information about backup via Services API in the Firebird documentation.

Post Reply