Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 16 total
Thread Backup of CS Data
Thu, Jan 10 2008 11:22 AMPermanent Link

Gordon Turner
I'm trying to code a backup procedure in my app using DBISAM 4.25 CS
(Delphi 7).  Every time I execute the Backup method, it returns False,
but I have no idea why.  I've tried closing all tables and queries then
setting the Session.Active and DB.Connected properties to True.  I've
made sure the UserID has backup and restore privileges.  I've tried
using the Admin user and port.  I've checked to make sure I pass a list
of table names.  None of which allows the Backup procedure to complete
normally.

Is there any way to tell why the backup failed.  I've got a Try/Except
block around the whole backup process, but no exceptions are raised.
How do I go about figuring out what's wrong?

Here's the code I'm using...

  TablesToBackup := TStringList.Create;
  try
    SetDatabaseAccess(Closed);
    try
      with TimeOffDataMod do begin
        for i := 0 to ComponentCount-1 do
          if (Components[i] is TDBISAMTable) then
            TablesToBackup.Add(TDBISAMTable(Components[i]).TableName);
        TimeOffSession.Active := True;
        TimeOffDB.Connected := True;
        if TimeOffDB.Backup(BackupFileName, 'Backup for '
              + DateToStr(Date), 0, TablesToBackup) then begin
          MessageDlgCtr('Your TimeOff CS Database has been backed up'
                + ' successfully.', mtInformation, [mbOK], 0);
          fBackupOK := True;
          Screen.Cursor := crHourGlass;
        end
        else
          MessageDlgCtr('A problem occurred backing up your TimeOff'
                + ' CS Database.' + MsgCrLf
                + 'Please try your backup again.',
                  mtWarning, [mbOK], 0 );
      end;
    except
      on E: Exception do
        ShowMessage('Backup error : ' + E.Message);
    end;
  finally
    TimeOffDataMod.TimeOffSession.Active := False;
    SetDatabaseAccess(Shared);
    FreeAndNil(TablesToBackup);
  end;

(The SetDatabaseAccess is a procedure that closes or opens all database
tables and queries in the data module.)

--
Gordon Turner
Mycroft Computing
http://www.mycroftcomputing.com
Thu, Jan 10 2008 11:55 AMPermanent Link

Gordon Turner
It suddenly occurred to me that the backup file has to be local to the
server - and now I have a backup.

The problem is that the user wants to be able to initiate a backup from
within the client application, and I want that user to be able to send
me a copy of that backup file.  Useful many times over when trying to
resolve a customer problem.

So, given that, how do I let the user pick a file name and folder local
to the server given the information available to the client application?

--
Gordon Turner
Mycroft Computing
http://www.mycroftcomputing.com
Thu, Jan 10 2008 1:04 PMPermanent Link

"Robert"

"Gordon Turner" <gordon@mycroftcomputing.com> wrote in message
news:7F366FCF-E5F5-48DB-85C2-D29A81B244D6@news.elevatesoft.com...
> It suddenly occurred to me that the backup file has to be local to the
> server - and now I have a backup.
>
> The problem is that the user wants to be able to initiate a backup from
> within the client application, and I want that user to be able to send me
> a copy of that backup file.  Useful many times over when trying to resolve
> a customer problem.
>
> So, given that, how do I let the user pick a file name and folder local to
> the server given the information available to the client application?
>

Not easy. I think it is a design error in DBISAM, but Tim almost banned me
from the newsgroups the last time it was discussed, so I live with it.

I use backups before any lengthy  operation that can not be undone, and
provide a restore capability. I ended up having the user create a subfolder
called backup under wherever they have the tables. Then I do this before
starting the application:

      asls.SessionType := stRemote;
      asls.RemotePort := 12006;
      asls.RemoteEncryption := true;
      asls.Open;
      dbdesc := db.RemoteDatabase;
      asls.GetRemoteDatabase(db.RemoteDatabase, dbdesc, serverpath);
      BackupDirectory := trim(ServerPath) + '\BACKUP';
      asls.Close;
      asls.RemoteEncryption := false;
      asls.RemotePort := 12005;

asls is my session name, and backupdirectory is a public string var in the
datamodule. I then do the backup to that folder. If you want that file sent
to you you need to have user access (at least read only) to the backup
folder, so that they can get to the backup file and send it to you.

Another option is to have the database folder accessible to the workstation
(UNC workstation mapping) and instead of using DBISAM backup, just crate a
ZIP archive using DAT IDX and BLB files (straight Windows, totally outside
DBISAM). That's the option I use when they need to send me files, you can
encrypt the ZIP archive and then just FTP it to your site. With any good ZIP
and FTP components it's just a few lines of code.

BTW to populate TablestoBackup do this

TablesToBackup := tStringList.Create;
dm.ASLS.GetTableNames(wDB, TablesToBackup);

where wDB is the database name

Robert

Thu, Jan 10 2008 4:44 PMPermanent Link

Gordon Turner
Robert wrote:
>
> Another option is to have the database folder accessible to the workstation
> (UNC workstation mapping) and instead of using DBISAM backup, just crate a
> ZIP archive using DAT IDX and BLB files (straight Windows, totally outside
> DBISAM). That's the option I use when they need to send me files, you can
> encrypt the ZIP archive and then just FTP it to your site. With any good ZIP
> and FTP components it's just a few lines of code.

The program currently uses the local tables option and I have been doing
a ZIP of the data files for years.  However, I have potential customers
who want to share data across a WAN, and local table performance is
generally poor, hence the C/S version.  But the customer wants the
ability to manually create backup files (apart from system backups that
may be performed).  I'll have to look at ways to let the client
application know where on the server to save the data.

> BTW to populate TablestoBackup do this
>
>  TablesToBackup := tStringList.Create;
>  dm.ASLS.GetTableNames(wDB, TablesToBackup);
>
> where wDB is the database name

Thanks for that little tip, much simpler than my method.

--
Gordon Turner
Mycroft Computing
http://www.mycroftcomputing.com
Thu, Jan 10 2008 4:46 PMPermanent Link

Gordon Turner
Looking at the Procedures and Events option in the Server Admin
module...  Am I correct in assuming that you need the Server Source to
add to these?  If not, where do I go about adding the code for a backup
procedure?

--
Gordon Turner
Mycroft Computing
http://www.mycroftcomputing.com
Thu, Jan 10 2008 5:58 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Gordon,

<< Looking at the Procedures and Events option in the Server Admin module...
Am I correct in assuming that you need the Server Source to add to these?
If not, where do I go about adding the code for a backup procedure? >>

No, all versions of DBISAM come with source code to the database server.
Just check out the servers\dbsrvr\source subdirectory under the main DBISAM
installation directory.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Jan 10 2008 6:24 PMPermanent Link

"Robert"

"Gordon Turner" <gordon@mycroftcomputing.com> wrote in message
news:29F9DA68-5552-4DFA-8A41-01315BE1803F@news.elevatesoft.com...
> may be performed).  I'll have to look at ways to let the client
> application know where on the server to save the data.
>

I considered at one time creating another "database" to be used just for
backups. That way, you can ask the server for the location (server relative)
of the backup databae,  process similar to what I described in the last
posting. If you have stndard naming conventions, it should work easily
enough. For example, the convention might be that the name of the backup
database is the database name + backup. So if you are running using database
name MYDATABASE, then you ask the server for the location of database
MYDATABASEBACKUP, and place your backups there. Of course, using server
admin on the server you can point MYDATABASEBACKUP to any folder.

It ended up not being necessary in my case, but something worth considering
if you need for the user to determine the location of the backup.

Robert


Fri, Jan 11 2008 11:09 AMPermanent Link

Gordon Turner
Tim Young [Elevate Software] wrote:
>
> No, all versions of DBISAM come with source code to the database server.
> Just check out the servers\dbsrvr\source subdirectory under the main DBISAM
> installation directory.

What I'd like to do is create a procedure on the server that will return
a list of file names from a server side database backup folder.  Then
the user can either select from the list and overwrite the backup or
create a new backup file.  The list will also be used to select a backup
file for restoring the data.  I don't need to browse folders, and the
folder will be hard coded as a relative folder to the data folder.

I'm stepping into new territory here so just to make sure I know what
I'm doing...

To add this "BackupFiles" procedure, I add the procedure name to the
Server through the Procedure/Procedure Users functions of the
ServerAdmin utility.  Then I edit the server code adding to the
Engine.OnProcedure event testing for the name of the procedure and
executing the appropriate code based on the name passed to the event.
The list of file names would be loaded into a TStringList object passed
back and forth in the RemoteSession via the RemoteParams property.

Am I missing anything here?
--
Gordon Turner
Mycroft Computing
http://www.mycroftcomputing.com
Fri, Jan 11 2008 2:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Gordon,

<< To add this "BackupFiles" procedure, I add the procedure name to the
Server through the Procedure/Procedure Users functions of the ServerAdmin
utility.  Then I edit the server code adding to the Engine.OnProcedure event
testing for the name of the procedure and executing the appropriate code
based on the name passed to the event.
The list of file names would be loaded into a TStringList object passed back
and forth in the RemoteSession via the RemoteParams property.  >>

Yep, that's all you need to do.   Well done. Smiley

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, Jan 13 2008 12:46 PMPermanent Link

Jason Lee
Gordon,

Depending upon how large your database is you can create the backup and
then stream it to your workstation using a server procedure.

~Jason Lee


Gordon Turner wrote:
> Looking at the Procedures and Events option in the Server Admin
> module...  Am I correct in assuming that you need the Server Source to
> add to these?  If not, where do I go about adding the code for a backup
> procedure?
>
Page 1 of 2Next Page »
Jump to Page:  1 2
Image