Page 1 of 1
Backup/Restore Services stop application from closing
Posted: Thu 05 Feb 2015 06:41
by kneighbour
I have a Delphi Xe7 application that I use to backup and restore Firebird databases. The backup and restore process itself works just fine. The problem is that once I run either a backup or a restore, I cannot close the application.
The application calls the OnClose event for the main form - but then I do not know what happens. The application form (there is only one) disappears, but the process does not quit.
This is basically the code. Very much the same for the REstore service.
Code: Select all
with IBCBackupService1 do
begin
Options := [];
if chkConvertExtTables.checked then
Options := options + [boConvertExtTables];
if chkIgnoreChecksums.checked then
Options := options + [boIgnoreChecksums];
if chkIgnoreLimbo.checked then
Options := options + [boIgnoreLimbo];
if chkMetadataOnly.checked then
Options := options + [boMetadataOnly];
if chkNoGarbageCollection.checked then
Options := options + [boNoGarbageCollection];
if chkNonTransportable.checked then
Options := options + [boNonTransportable];
if chkOldMetadataDesc.checked then
Options := options + [boOldMetadataDesc];
Active := True;
try
Verbose := True;
Database := txtSourceDB.Text;
BackupFile.text := stBackup;
ServiceStart;
while not Eof do
begin
Msg(GetNextLine); //display in memo component
application.processmessages;
end;
finally
Detach;
Active := False;
end;
I am thinking that perhaps there should be some way to stop the service. There is a ServiceStart, but no ServiceStop.
Any suggestions?
Re: Backup/Restore Services stop application from closing
Posted: Thu 05 Feb 2015 11:40
by ViktorV
Backup process cancel is not supported in our components, since this functionality is not supported in FireBird. This is described at
http://www.firebirdfaq.org/faq63/
Re: Backup/Restore Services stop application from closing
Posted: Thu 05 Feb 2015 11:45
by kneighbour
Not sure why you mentioned cancelling the backup (or restore) process. My problem has nothing to do with that (or has it?). The backup (or restore) process works just fine and completes just fine.
I simply want to close my application.
Re: Backup/Restore Services stop application from closing
Posted: Thu 05 Feb 2015 12:34
by ViktorV
Unfortunately, we could not reproduce the issue. Please send a small sample to demonstrate the issue to us, including a script to create and fill in the test database object.
Re: Backup/Restore Services stop application from closing
Posted: Thu 05 Feb 2015 21:34
by kneighbour
In your system, once you do a Backup (or Restore), you can close your application ok? You do not provide any examples of using these components, so I am assuming that my code is correct?
My current system is Delphi XE7, and IBDAC 5.4.11. I used to have this program in D7 and IBDAC 5.4.10, and that version worked ok.
Not sure why you would want a script file - this is a backup/restore problem. Try backing up any database (I guess it could even be empty). I showed the code that I use to perform the backup. The Restore code is pretty much the same and has the same problem.
The problem is NOT in the backup/retore functionality itself - it performs just fine. The problem is I cannot close the application afterwards.
In my situation, what I am trying to do is develop an application to do a backup, then a restore, then close the program. The intention is to do this once a week automatically and unattended. The fact that the application does not quit at the end of the backup/restore is a fatal problem.
My core problem is that in Firebird doing a gfix -SWEEP does not seem to do much at all. It is only by doing a backup/restore that the Firebird files are cleaned up and kept at a manageable size. I need some way to automate this.
Re: Backup/Restore Services stop application from closing
Posted: Fri 06 Feb 2015 10:08
by ViktorV
We have tested database backup creation and database restore, and saw that the operations were performed successfully and the application closed every time.
Please execute the following code and check if the problem is reproduced on it:
Code: Select all
program Project;
{$APPTYPE CONSOLE}
uses
System.SysUtils, IBCAdmin, IBC;
var
IBCBackupService: TIBCBackupService;
IBCRestoreService: TIBCRestoreService;
IBCConnection: TIBCConnection;
begin
IBCConnection := TIBCConnection.Create(nil);
try
IBCConnection.Server := Server;
IBCConnection.Port := Port;
IBCConnection.Database := NewDataBase;
IBCConnection.ClientLibrary := ClientLibrary;
IBCConnection.Username := 'sysdba';
IBCConnection.Password := 'masterkey';
IBCConnection.Params.Clear;
IBCConnection.Params.Add('USER ''SYSDBA''');
IBCConnection.Params.Add('PASSWORD ''masterkey''');
IBCConnection.Params.Add('PAGE_SIZE 4096');
IBCConnection.Params.Add('DEFAULT CHARACTER SET WIN1251');
try
IBCConnection.Connect;
IBCConnection.DropDatabase;
except
end;
IBCConnection.CreateDatabase;
IBCConnection.ExecSQL('CREATE TABLE TEST(ID INTEGER, TXT VARCHAR(40))');
IBCConnection.ExecSQL('INSERT INTO TEST VALUES(1, ''Test text'')');
IBCConnection.Disconnect;
WriteLn('Create Ok');
IBCBackupService := TIBCBackupService.Create(nil);
try
IBCBackupService.Server := IBCConnection.Server;
IBCBackupService.Port := IBCConnection.Port;
IBCBackupService.Username := IBCConnection.Username;
IBCBackupService.Password := IBCConnection.Password;
IBCBackupService.BackupFile.Text := BackupFile;
IBCBackupService.Database := IBCConnection.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 := IBCConnection.Server;
IBCRestoreService.Port := IBCConnection.Port;
IBCRestoreService.Username := IBCConnection.Username;
IBCRestoreService.Password := IBCConnection.Password;
IBCRestoreService.BackupFile.Text := BackupFile;
IBCRestoreService.Database.Text := IBCConnection.Database;
IBCRestoreService.Options := IBCRestoreService.Options + [roReplace];
IBCRestoreService.Verbose := True;
IBCRestoreService.Active := True;
IBCRestoreService.ServiceStart;
while not IBCRestoreService.Eof do begin
IBCRestoreService.GetNextLine;
end;
WriteLn('Restore Ok');
finally
IBCRestoreService.Active := False;
IBCRestoreService.Free;
end;
ReadLn;
finally
IBCConnection.Free;
end;
end.
Re: Backup/Restore Services stop application from closing
Posted: Mon 09 Feb 2015 01:25
by kneighbour
Your console app works just fine.
I finally found the problem - if I have service.verbose TRUE, then I cannot close the application. If I set VERBOSE:=false then everything works just fine. Also MUCH faster (unsurprising).
Only in XE7. In D7, it all works just fine, whatever I set VERBOSE to.
Re: Backup/Restore Services stop application from closing
Posted: Mon 09 Feb 2015 11:44
by ViktorV
Glad to see that the issue was resolved. We are investigating this behavior of IBDAC, and we will try to find out why the Verbose property of the TIBCBackupService and TIBCRestoreService components affects application behavior in RAD Studio ХЕ7 in such a way. We will inform you about the results.
Re: Backup/Restore Services stop application from closing
Posted: Tue 10 Feb 2015 22:48
by kneighbour
thanks
Re: Backup/Restore Services stop application from closing
Posted: Wed 18 Feb 2015 00:49
by kneighbour
I found the problem. It is nothing to do with your components.
I record the progress the backup progress. ie
this works
Code: Select all
while not Eof do
begin
Memo1.lines.Add(GetNextLine);
end;
Code: Select all
while not Eof do
begin
WriteToMyLogFile(GetNextLine);
end;
That does not work. Well, it all works, but for some reason the program will not exit. I guess the log file code is blocking it somehow?
Anyway, what I do now is this - and it works.
Code: Select all
while not Eof do
begin
Memo1.lines.Add(GetNextLine);
end;
WriteToMyLogFile(Memo1.lines.text);
Anyway - just in case you were trying to work out a problem with your components - don't bother.
Re: Backup/Restore Services stop application from closing
Posted: Thu 19 Feb 2015 09:29
by ViktorV
Glad to see that the issue was resolved. Feel free to contact us if you have any further questions about IBDAC.