Icon View Thread

The following is the text of the current message along with any replies.
Messages 31 to 31 of 31 total
Thread HOT BACKUP LOCK ISSUES - Please Advise
Thu, Feb 29 2024 2:13 PMPermanent Link

Andrew Hill

Terry - with a few adjustments we have success - Thank You (see Andy for the changes, I hope this long winded thread helps others in the future):-

// Andy NOTE: (TIM IS AUTOMATICALLY ADDING THE BACKUP FILE EXTENSION TO THE BackUpFileName SO WE MUST REMOVE THE EXTENSION BEFORE USE)
function TUniServerModule.RestoreDatabase(UserName: String): Boolean; // Will Log UserName Who Requested Restore Later
 //////////////////////////////////////////////////////////////////////////////
 function DoRestore(Source: TEDBSession): Boolean;
 var
   lSession: TEDBSession;
   ds: String;
 begin
   Result:= False;
   Source.FreeCachedSQLStmts('');
   Source.FreeCachedFuncProcs('');
   Source.Close;
   lSession:=             TEDBSession.Create(nil);
   lSession.SessionType:= Source.SessionType;
   // Andy (NEEDS SESSION NAME)
   DateTimeToString(ds, 'yyyymmddhhmmsssss', Now());
   lSession.SessionName:= 'tmp'+ds;
   // Andy
   case lSession.SessionType of
     stLocal:  begin
                 lSession.LocalConfigPath:= Source.LocalConfigPath;
                 lSession.LocalConfigName:= Source.LocalConfigName;
                 // Andy (NEEDS LOGIN USER/PASSWORD)
                 lSession.LoginUser:=       Source.LoginUser;
                 lSession.LoginPassword:=   Source.LoginPassword;
                 // Andy
               end;
     stRemote: begin
                 lSession.RemoteHost:=      Source.RemoteHost;
                 lSession.RemoteAddress:=   Source.RemoteAddress;
                 lSession.RemotePort:=      Source.RemotePort;
                 lSession.LoginUser:=       Source.LoginUser;
                 lSession.LoginPassword:=   Source.LoginPassword;
               end;
   end;
   ////////////////////////////////////////////////////////////////////////////
   try
     lSession.Execute('RESTORE DATABASE '+ProjectName+' '+
                      'FROM "'+RestoreBackupName+'" '+
                      'IN STORE "'+ProjectName+'-BK" '+
                      'INCLUDE CATALOG ;');
     Result := True;
   except
   end;
   lSession.Free;
end;
////////////////////////////////////////////////////////////////////////////////
begin

 //////////////////////////////////////////////////////////////////////////////
 Result:=                      False;
 TwentyFourHourTimer.Enabled:= False;
 SrvDatabase.Close;
 SrvSession.Close;
 AppEngine.Close;

 //////////////////////////////////////////////////////////////////////////////
 // Andy (ME BEING DOUBLY CAUTIOUS)
 if FileExists(AppDataPath+'EDBDatabase.EDBLck') = True then begin
   try
     DeleteFile(PChar(AppDataPath+'EDBDatabase.EDBLck'));
   except
   end;
 end;
 //
 if FileExists(EdbConfigPath+'EDBConfig.EDBLck') = True then begin
   try
     DeleteFile(PChar(EdbConfigPath+'EDBConfig.EDBLck'));
   except
   end;
 end;
 // Andy

 //////////////////////////////////////////////////////////////////////////////
 AppEngine.Open;

 //////////////////////////////////////////////////////////////////////////////
 // Andy (MUST REOPEN SESSION HERE BEFORE DoRestore)
 SrvSession.Open;
 try
   Result:= DoRestore(SrvSession);
 except
 end;
 // Andy

 //////////////////////////////////////////////////////////////////////////////
 // Andy (NOT OPEN HERE, OPEN ABOVE FOR DoRestore)
 //SrvSession.Open;
 // Andy
 SrvDatabase.Open;
 TwentyFourHourTimer.Enabled:= True;

end;
« Previous PagePage 4 of 4
Jump to Page:  1 2 3 4
Image