Page 1 of 1
How to Backup Db on Remote Host to local drive
Posted: Wed 30 May 2018 08:50
by sugi
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.
Re: How to Backup Db on Remote Host to local drive
Posted: Wed 30 May 2018 14:12
by ViktorV
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.
Re: How to Backup Db on Remote Host to local drive
Posted: Thu 31 May 2018 01:45
by sugi
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?
Re: How to Backup Db on Remote Host to local drive
Posted: Thu 31 May 2018 08:22
by ViktorV
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.