Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread Backup Database not working always???
Wed, Sep 22 2010 3:43 AMPermanent Link

gripsware

gripsware datentechnik gmbh

In my application the user is able to execute a database within application, and periodically when closing the application. Therefor I have settings "Automatic backup every ... days" and "keep ... number of backup files". See my code below. To make a difference between user backups and auto backups the backup files have different Prefix.

The backup call from my application is:

procedure DoBackup(const aPrefix : string; const aKeepFiles: integer);
begin
  // Delete oldest Bakup File(s), except the Prefix of Backup File is "update_"
  ClearFilesInStore('Backup', aKeepFiles, 'Left(Name, 7) <> ' + QuotedStr('update_')');
  // Run Backup
  BackupDatabase(aPrefix);
end;

So I call from menu button click the function:
DoBackup('user');
When closing app and the timediff since last auto backup is number of days as in settings:
DoBackup('auto');

This works fine, BUT sometimes the backup file is not CREATED!!! Backup operation runs without Error, but the file is sometimes created sometimes not. I could not find a way when it works and when not?!?!?

I use first elevateDB 2.03 Build 20 unicode and changed now to 2.04 Build 2, but same problem. Developing with RAD Studio 2010... Connection is local, environment is also local.
The "ClearFilesInStore" works in any case, but backup not. So I have then 1 Backup file less in backup store if saving of backup file fails.
The next time I try the backup it works.... sometimes not.

DO YOU HAVE ANY IDEA?!?!?

Regards
Michael

//------------------------------- Code Section ----------------------------------------------
//
function TdmEngine.BackupDatabase(const aPrefix : string) : boolean;
var
 aFilename : string;
begin
 aFilename := StringReplace(aPrefix + '_' + DBDatabase.Database, ' ', '', [rfReplaceAll]) +
                            FormatDateTime('_yyyymmdd_hhnnss', Now);

 try
   DBSession.Execute('set backups store to "Backup"');
   DBSession.Execute('BACKUP DATABASE "' + DBDatabase.Database + '"' +
                     ' AS "' + aFileName + '"' +
                     ' TO STORE "Backup"' +
                     ' INCLUDE CATALOG');
   Result := True;
 except
   Result := False;
 end;
end;

function TdmEngine.ClearFilesInStore(const aStoreName: string;
 const aKeepFiles: integer; const aFilter: string): integer;
var
 aFilesQry : TEDBQuery;
 slFileNames : TStringList;
begin
 Result      := 0;
 slFileNames := TStringList.Create;
 aFilesQry   := QueryFilesOfStore(aStoreName);
 try
   if aFilter <> '' then
   begin
     aFilesQry.Filter := aFilter;
     aFilesQry.Filtered := True;
   end;

   aFilesQry.First;
   while not aFilesQry.Eof do
   begin
     slFileNames.Add(aFilesQry.FieldByName('Name').AsString);
     aFilesQry.Next;
   end;

   while (slFileNames.Count >= aKeepFiles) and (slFileNames.Count > 0) do
   begin
     dmEngine.ExecuteQuery('DELETE FILE "' + slFileNames[0] + '" FROM STORE "' + aStoreName + '"', '', NULL);
     slFileNames.Delete(0);
     Result := Result + 1;
   end;
 finally
   aFilesQry.Free;
   slFileNames.Free;
 end;
end;

function TdmEngine.QueryFilesOfStore(const aStoreName: string): TEDBQuery;
begin
 Result := CreateQuery;
 ExecuteQuery(Format('set files store to "%s"', [aStoreName]), '', NULL);
 ExecuteQuery('select * from configuration.Files order by CreatedOn', '', NULL, Result);
end;
Wed, Sep 22 2010 4:00 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Michael


There are only two things that come to mind. First, and most likely is that ElevateDB is unable to get a lock on one of the tables or catalog. Second is the OS saying no.

Your try..except block is eating any exception that is raised so you're not getting any help from it. You need to at least catch the exception and log it.

Roy Lambert [Team Elevate]
Wed, Sep 22 2010 4:45 AMPermanent Link

gripsware

gripsware datentechnik gmbh

Roy,

thanks for your fast response. I have now commented out the try..except block to catch the exceptions. The crazy thing is, that I now get my backup files without loss. I will keep it in watch to see what happens ....

Regards
Michael

Roy Lambert wrote:

Michael


There are only two things that come to mind. First, and most likely is that ElevateDB is unable to get a lock on one of the tables or catalog. Second is the OS saying no.

Your try..except block is eating any exception that is raised so you're not getting any help from it. You need to at least catch the exception and log it.

Roy Lambert [Team Elevate]
Wed, Sep 22 2010 9:02 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< This works fine, BUT sometimes the backup file is not CREATED!!! Backup
operation runs without Error, but the file is sometimes created sometimes
not. I could not find a way when it works and when not?!?!? >>

Check the logged events for the EDB configuration:

SELECT * FROM Configuration.LogEvents

If there is any issue with the backup, then it should show up there
(provided that you've kept the default TEDBEngine log settings).

--
Tim Young
Elevate Software
www.elevatesoft.com
Wed, Sep 22 2010 10:13 AMPermanent Link

gripsware

gripsware datentechnik gmbh

Tim,

thanks I checked the logs, and there was always Information entries with the backups, no Errors. I attach a screenshot.

Michael

"Tim Young [Elevate Software]" wrote:

Michael,

<< This works fine, BUT sometimes the backup file is not CREATED!!! Backup
operation runs without Error, but the file is sometimes created sometimes
not. I could not find a way when it works and when not?!?!? >>

Check the logged events for the EDB configuration:

SELECT * FROM Configuration.LogEvents

If there is any issue with the backup, then it should show up there
(provided that you've kept the default TEDBEngine log settings).

--
Tim Young
Elevate Software
www.elevatesoft.com



Attachments: elevate_log.jpg
Thu, Sep 23 2010 10:25 AMPermanent Link

gripsware

gripsware datentechnik gmbh

Tim,

it happened again. See the screenshot, log file shows the backup with filename, but store on the leftside miss this file!!!

Regards
Michael

"Tim Young [Elevate Software]" wrote:

Michael,

<< This works fine, BUT sometimes the backup file is not CREATED!!! Backup
operation runs without Error, but the file is sometimes created sometimes
not. I could not find a way when it works and when not?!?!? >>

Check the logged events for the EDB configuration:

SELECT * FROM Configuration.LogEvents

If there is any issue with the backup, then it should show up there
(provided that you've kept the default TEDBEngine log settings).

--
Tim Young
Elevate Software
www.elevatesoft.com



Attachments: elevate_log2.jpg
Thu, Sep 23 2010 4:18 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< thanks I checked the logs, and there was always Information entries with
the backups, no Errors. I attach a screenshot. >>

Did you verify that you're logging warnings/errors in the server/engine
settings ?

--
Tim Young
Elevate Software
www.elevatesoft.com
Thu, Sep 23 2010 4:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mon, Sep 27 2010 3:25 AMPermanent Link

gripsware

gripsware datentechnik gmbh

Tim,

yes, I have these 3 checkboxes checked. I´m wondering about, that it sometimes works and sometimes not. In my application I uses always the same code!

Do you think it can be a problem, that I call the "set files store to "Backup"" in my "ClearFilesInStore" function? Can I reset this function to standard value?

Regards
Michael


"Tim Young [Elevate Software]" wrote:

I mean this property:

http://www.elevatesoft.com/manual?action=viewprop&id=edb2&product=d&version=7&comp=TEDBEngine&#8733;=LogCategories

--
Tim Young
Elevate Software
www.elevatesoft.com


Tue, Sep 28 2010 2:57 AMPermanent Link

gripsware

gripsware datentechnik gmbh

Tim,

the backup is definitively not working. See my attached screenshot, the backups 1 and 2 was in the log, but not in the store 3. Please help me, can it help you if I send you a backup of my DB? I think it´s a problem in the Unicode Version, because I have a nother project running in ANSI, where I have never seen this problem!

regards
Michael

Michael Reisch wrote:

Tim,

yes, I have these 3 checkboxes checked. I´m wondering about, that it sometimes works and sometimes not. In my application I uses always the same code!

Do you think it can be a problem, that I call the "set files store to "Backup"" in my "ClearFilesInStore" function? Can I reset this function to standard value?

Regards
Michael


"Tim Young [Elevate Software]" wrote:

I mean this property:

http://www.elevatesoft.com/manual?action=viewprop&id=edb2&product=d&version=7&comp=TEDBEngine&#8733;=LogCategories

--
Tim Young
Elevate Software
www.elevatesoft.com





Attachments: elevate_log3.jpg
Page 1 of 2Next Page »
Jump to Page:  1 2
Image