Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Implementing "Daily Backup" OnServerScheduledEvent
Thu, Oct 19 2006 5:08 PMPermanent Link

Royce
I am using C++ Builder 6 with the DBISAM Client/Server version 4.24.  Presently we install
the out of thebox version of dbsrvr.exe as a service on the server machine.  I trying to
implement the "DailyBackup" example that is in the manual.

It is my understanding that Main.pas of the dbsrvr source needs to be modified.  However,
I don't have Delphi, only C++ Builder, and I don't have a way to compile/build dbsrvr.exe
with the tools I have.

Thus, I created a basic application with just a DBISAMEngine component, configured as a
server, and a button to call the DailyBackup code.  It executes without errors, and I can
connect to the server using srvadmin.exe, but a backup file is never created.  What am I
overlooking?  

void __fastcall TMainForm::LinkServerEngineServerScheduledEvent(
     TObject *Sender, const AnsiString EventName, bool &Completed)
{
  AnsiString TempDescription="";
  AnsiString TempPath="C:\\Link\\DBBackups\\";
  AnsiString SourceDatabase = "C:\\Link\\Db";

  if (AnsiCompareText(EventName,"DailyBackup")==0)
  {
     // Create a new session component, remembering
     // the multi-threading requirements of DBISAM
     // for session names
     TDBISAMSession *TempSession=new TDBISAMSession(this);
     try
     {
        TempSession->SessionName="DailyBackup"+
            IntToStr(_threadid);
        TempSession->Active=true;
        // Create a new database component
        TDBISAMDatabase *TempDatabase=new TDBISAMDatabase(this);
        try
        {
           TempDatabase->SessionName=TempSession->SessionName;
           TempDatabase->DatabaseName="DailyBackup";
           // Get the actual local path for the Main
           // database
           Engine()->GetServerDatabase("LinkCS",
                                       TempDescription,
                                       TempPath);
           TempDatabase->Directory=TempPath;
           TempDatabase->Connected=true;
           TStringList *BackupFiles=new TStringList;
           try
           {
             //TempSession->GetTableNames(SourceDatabase,BackupFiles);
             TempSession->GetTableNames(TempDatabase->DatabaseName,BackupFiles);
             TReplaceFlags ReplaceAllOccurances;
             ReplaceAllOccurances << rfReplaceAll;
             try
             {
               Completed=TempDatabase->Backup(
                   IncludeTrailingBackslash(TempPath)+"backup"+
                   StringReplace(DateToStr(Now()),"/",
                                 "",ReplaceAllOccurances)+ ".bkp",
                   "Daily Backup for " + DateToStr(Now()),6,BackupFiles);
             }
             catch(...)
             {
               ShowMessage("We had an error");
               throw;
             }
           }
           __finally
           {
             delete BackupFiles;
           }
           TempDatabase->Connected=false;
        }
        __finally
        {
           delete TempDatabase;
        }
     }
     __finally
     {
       delete TempSession;
     }
  }
  else
  {
   Completed=true;
  }
}
//---------------------------------------------------------------------------



Attachments: Server.zip
Fri, Oct 20 2006 2:31 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Royce,

<< Thus, I created a basic application with just a DBISAMEngine component,
configured as a server, and a button to call the DailyBackup code.  It
executes without errors, and I can connect to the server using srvadmin.exe,
but a backup file is never created.  What am I overlooking?  >>

Via the Server Administration Utility, if you load the log from the database
server while it is running, does the log indicate that the scheduled event
completed successfully ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Image