Subject Re: [firebird-support] How to determine if database is in backup mode
Author Paul Vinkenoog
Hi Tom,

> If you backup a database using nbackup, and the nbackup process dies for some
> reason, the database gets stuck in backup mode because the 'alter database
> end backup' statement is never run.
> How can I determine if a database is in backup mode? If it is, I can
> execute 'alter database end backup' or use 'nbackup -N' before I start doing
> the next nbackup.

Look for the presence of the .delta file. I'm not sure if it is created right away (I think it is) or upon the first mutation, so to be sure you could first make a trivial mutation that you can later reverse.

If you're running 2.1, an even better way is to SELECT MON$BACKUP_STATE FROM MON$DATABASE :
0 = normal operation
1 = stalled (i.e. locked, main file frozen)
2 = merge (busy merging delta in main file)

Paul Vinkenoog