1

I'm using Firebird 3.0 nbackup to lock + copy + unlock each night.

If some steps fail or are skipped e.g. due to system restart (updates), it may happen that the master is not unlocked (-N). Next night, it will already be in locked state, but the scheduled backup task will lock it again (-L).

Is this safe?

Will the second -L have any effect, or is it a no-op, so a single unlock (-N) will restore it to normal state? Or do I have to safeguard against a second lock (-L) if it's already in locked state?

5
  • In StackOverflow there is a version specific tag "firebird-3.0". If anyone can add that to this site it would be nice. Jan 13, 2020 at 11:20
  • Hmm... with 84 posts in ~ 10 years, it's probably not worth it? It's probably worthwhile having multiple tags for the likes of MySQL and SQL Server which have a huge following, but not for fb. Don't get me started on the tragedy of a superior server (fb) being outdone by MySQL in the popularity stakes! :-( There are a few big hitters in the fb world who post here and (I'm pretty sure) follow the tag! I'm just curious as to why you have to lock the db - I thought fb had hot backups from years ago? p.s. welcome to the forum! :-)
    – Vérace
    Jan 13, 2020 at 12:05
  • @Vérace The DB is 190+ Gbyte and gbak takes quite some time + a restore takes even longer, so nbackup with file copy is more efficient. Also, it provides fresh copies to use for test/dev purposes, which i great! Note: nbackup -L does provide for "hot backups", but by means of freezing the main database file and (temporarily) redirecting all writes to a separate (delta) file. Jan 13, 2020 at 15:31
  • @Vérace Firebird has most support activity in mailing lists. I'm trying to increase visibility and get better availability of Q&A by posting my questions on StackExchange instead. Trying to convince fellow users to do the same, meeting strong resistance though. Jan 13, 2020 at 15:34
  • 1
    The problem for Firebird of course is the presence of PostgreSQL - and it is truly the best F\LOSS database out there - its range of features is way superior to fb's. However, I definitely think that fb is superior to MySQL - but I'm afraid that ship has sailed! :-( Thanks for the explanation of your backup strategy - of course, cold backups have their place! Best of luck with your campaign - in College I'm planning on doing something with database benchmarks with my project - and rest assured, I will be including fb in my lineup! :-)
    – Vérace
    Jan 13, 2020 at 17:01

1 Answer 1

1

Executing nbackup -L when a database is already locked will produce an error (and the executable will return exit code 1 instead of 0):

[
PROBLEM ON "begin backup".
unsuccessful metadata update
-ALTER DATABASE failed
-Database is already in the physical backup mode
SQLCODE:-607
]

In that case, Firebird (or nbackup) won't change anything in the state of the database. So the locked database will remain locked.

Continuing would be fine in theory (as the database is locked), but I don't think it is a good idea to just ignore errors and continue, because it could be a different error than this. So, for proper error checking, you would need to check if the error is "Database is already in the physical backup mode" and not some other error.

As an aside, you can achieve the same effect with ALTER DATABASE BEGIN BACKUP and ALTER DATABASE END BACKUP, which will also work with SuperServer mode (as the nbackup tool needs direct file access, while SuperServer uses an exclusive lock on the file).

2
  • Thanks! Are you saying that nbackup -L is not safe (as in may cause database corruption or similar) for a superserver, or are you saying that nbackup -L may fail if the FB superserver process is currently attached to this database? Jan 14, 2020 at 9:07
  • 1
    @KjellRilbe nbackup -L will fail when Firebird SuperServer is attached to the database, as SuperServer opens the file with exclusive access. It will not cause corruption. Jan 14, 2020 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.