Subject GBAK documentation: -REPLACE, -RECREATE (OVERWRITE)
Author Michael Ludwig
Follow-up on a recent thread and some pointers to GBAK docs:

Re: Copy of the current db not updating generators
http://tech.groups.yahoo.com/group/firebird-support/message/118211

Norman Dunbar schrieb am 31.05.2012 um 17:04 (+0100):

> Plus a whole chapter on making backups under various conditions here:
>
> http://www.firebirdsql.org/file/documentation/reference_manuals/user_manuals/html/gbak-recipies.html

That guide has "gbak -replace overwrite" throughout the page, which is
not what the options in "gbak -?" show, and it doesn't appear to work
either, at least not with 2.5.1 on Windows/32.

The correct syntax for overwriting a database in 2.5.1 (apparently 2.0
and above) is either one of:

gbak -replace_database …
gbak -replace …
gbak -rep …

gbak -recreate_database overwrite …
gbak -recreate over …
gbak -r o …

As switch, anything from -R to -RECREATE_DATABASE, and as keyword,
anything from O to OVERWRITE.

Of course, when overwriting, be sure to know what you're doing. Which is
what FAQ 181 points out, going further to caution people against using
the -replace switch, which prior to 2.0 was abbreviated as just -r
instead of -rep:

Why did 'gbak -r' overwrite my database?

[…] You should always use -c to create a new database from backup
and then simply rename the database file. This will save you a lot
of trouble […] Also, if you use -r and restore fails for some reason
you won't have any functional database as the old one is deleted when
restore starts.

This has been changed in Firebird 2, now -R means RECREATE database,
and will not overwrite existing database file.

-- http://www.firebirdfaq.org/faq181/

So all in all, using -replace (-recreate overwrite) throughout in a
guide on making backups might not be the best choice under each and
every circumstances.

In addition, FAQ 181 is slightly wrong or out of date:

If you desire the old behaviour of -R switch, you can use -REP or -R
-O, where -O means OVERWRITE.

The last part is wrong and doesn't work. There is no "-R -O"; the
correct option is "-R OVERWRITE" or "-R O", where OVERWRITE is somewhat
of a syntactical oddity, an optional keyword argument to a switch. So
that should read:

If you desire the old behaviour of -R switch, you can use -REP or -R
OVERWRITE (-R OVER or -R O), where OVERWRITE/OVER/O is an optional
keyword argument to -R.

One remark about the rewiring of the -R switch to -RECREATE in 2.0 and
up versus -REPLACE before. I think it is a bit unfortunate and increases
confusion. Old docs and old knowledge keep sticking around and never
entirely disappear. And imagine being accustomed to the safe 2.0 and up
behaviour of -R and then unsuspectingly coming to an older installation
and doing a -REPLACE you didn't intend. Anyway, the case is hopefully
rare enough. But this shift in meaning is just one more thing to keep
in mind. It might have been better to just disallow the shorthand -R
notation and require the user to specify -REPLACE.

I hope this last remark didn't make my comments too much of a rant …

--
Michael Ludwig