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,
Use TIBCRestoreService to restore backup on remote server
Re: Use TIBCRestoreService to restore backup on remote server
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):
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.