Subject Re: Can I copy the embedded database file on the fly?
Author Jeff Lynn
Thanks for all the replies.

Since I don't know how to invoke backup in embedded mode, so
I ended up thinking along the line of using semaphore to control
access to the embedded database and then have my session management
thread backup the database file according to a configuratble days period.

So from Ivan's post, it seems that if my management thread gain
exclusive access to the database by gaining the semaphore first,
followed by excuting the "ALTER DATABASE BEGIN BACKUP" SQL before
start file copy, and executes the "ALTER DATABASE END BACKUP" will
address the problem of having the backed up copy of the database file
being corrupted.

I will give it a try! Thanks!

Jeff


--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:
>
> > I gave some more thought to this problem, and my theory of using
> > NBackup would not work because of the embedded engine, unless your
> > process disconnected totally from the database, unless NBackup is
> > available through some API that I am not yet familiar with.
>
> For full file-level backup, all you need to do is execute
> ALTER DATABASE BEGIN BACKUP
> then make copy of db file, then
> ALTER DATABASE END BACKUP
>
> > Creating a thread and connecting to the services API to do a backup
> > from that thread is the best solution as it guarantees the backup will
> > not be corrupt and does not interfere at all with your application.
>
> Both methods (NBackup-like and ServicesAPI-GBAK) are safe,
> so you can choose which method is better for you
> (i.e. either fast physical copy, or slower logical backup)
>
> Ivan
> http://www.volny.cz/iprenosil/interbase/
>