FirebirdSQL logo

Gbak Log File Cannot Be Overwritten

If you specify a log filename with the -⁠y <log file> switch, and the file already exists, then even though the firebird user owns the file, and has write permissions to it, gbak cannot overwrite it.You must always specify the name of a log file that doesn’t exist.On Linux systems, the following might help:

tux> # Generate unique backup and log filename.
tux> FILENAME=employee_`date "+%Y%m%d_%H%M%S"`

tux> # Shut down and Backup the database
tux> gfix -shut -tran 60 employee
tux> gbak -backup employee /backups/${FILENAME}.fbk -y /logs/${FILENAME}.log -v

The above is quite useful in as much as it prevents you from overwriting previous backups that may be required.The downside is that you now need to introduce a housekeeping system to tidy away old, unwanted backups to prevent your backup area filling up.

Use of stdin or stdout Filenames

Gbak recognizes the literal strings stdin and stdout as source or destination filenames.In POSIX systems, when the standard input and/or standard output channels are used, it is not permitted to execute seek operations on these channels.Using stdin or stdout as filenames with gbak will force gbak to use processing that will not seek on the input or output channels, making them suitable for use in pipes — as per the examples in the recipes section above.

These filenames, while they appear to be POSIX names, are definitely not synonyms for /dev/stdin or /dev/stdout, they are simply literals that gbak checks for while processing its parameters.Do not attempt to use names /dev/stdin or /dev/stdout in a piped process as it will most likely fail.

If you wish to create a backup file actually named either stdin or stdout, then you should specify the filename as a full, or relative, path name such as ./stdin or ./stdout, which causes gbak to treat them as a literal filename rather than a special filename that causes different to normal processing during the backup or restore process.

Document history

The exact file history is recorded in the firebird-documentation git repository; see https://github.com/FirebirdSQL/firebird-documentation

Revision History

1.18

17 Apr 2024

MR

Moved and reworded -NODBTRIGGERS as it is a backup switch, not a restore switch (#207)

1.17

2 Apr 2024

MR

Protocol names are lowercase (#205)

1.16

24 Feb 2024

MR

Fixed rendering issue with -⁠INCLUDE[_DATA] syntax

1.15

24 Feb 2024

MR

Include gbak name in the document title, making it the same as on https://firebirdsql.org/en/reference-manuals/

1.14

17 Feb 2024

MR

  • Fix wrong rendering due to wrong double quotes

  • -⁠STATISTICS also displayed for -⁠VERBINT

  • -⁠USER cannot be abbreviated to -⁠U

  • Added notes on -⁠REPLICA vs -⁠MODE

  • Added word-joiner in commandline switches between minus (-) and first character to ensure they aren’t broken up on word wrap

  • Add links from usage instruction to relevant sections

1.13

16 Feb 2024

MR

  • Reordered document history so most recent changes are on the top

  • Some copy-editing and formatting of the document history

  • Added common options added in Firebird 3.0, 4.0, and 5.0, and some from 2.5 that weren’t documented yet (documented with minimal information, will be expanded later)

  • Removed common options repeated with "see above" in the backup and restore options

  • Reordered restore options to put the main restore options (-⁠CREATE_DATABASE and -⁠RECREATE_DATABASE [OVERWRITE]) first

  • Misc. copy-editing of commandline options

  • Convert commandline options from definition lists to sections

  • Replaced usage of -⁠REPLACE_DATABASE (or its abbreviations) in examples with -⁠RECREATE_DATABASE OVERWRITE (or abbreviations)

  • Added more information on -⁠CRYPT, -⁠DIRECT_IO, -⁠KEYHOLDER, -⁠KEYNAME, -⁠PARALLEL, -⁠REPLICA, -⁠VERBINT

1.12

18 Jun 2020

MR

Conversion to AsciiDoc, minor copy-editing

1.11

1 May 2013

ND

A correction to the above change to the -⁠use_[all_space] command line switch — it affects all subsequent pages as well as the ones created during the restore.

1.10

1 May 2013

ND

Slight update to the -⁠use_[all_space] command line switch, to explain how it works in a more understandable manner.

1.9

11 Apr 2013

ND

  • A section has been added to explain how to speed up your backups.

  • A note has been added to the -⁠service option to explain that it’s use is not restricted to remote databases.

  • Syntax errors in some examples corrected.

1.8

14 Jan 2013

ND

Further updates to document the use of the stdin and stdout filenames in backups and restores.A section has been added to Gbak Caveats giving more in depth detail about these two special filenames.

1.7

11 Jan 2013

ND

  • Updated to document the use of the stdin and stdout filenames in backups and restores, which allow backups to be written to or read from standard input and standard output.

  • A section was added on the use of the above to clone databases without requiring an intermediate backup file.

  • An additional section was also added to show how — using the above in conjunction with SSH — backup and/or restore operations could be carried out on databases where one or both of the databases in question, are remote.

  • A few minor formatting errors, URLs and some examples were corrected.

  • Also added an example of a metadata only backup and restore.

1.6

11 Oct 2011

ND

*Updated to cover Firebird 2.5 changes.* Corrected description of -⁠g[arbage_collect] switch.* Lots of spelling mistakes corrected.

1.5

31 Mar 2011

ND

Updated the -⁠z option to indicate that it does carry out a backup.

1.4

09 Aug 2010

ND

Noted that gbak defaults to running a backup or recover according to the first filename parameter supplied.

1.3

24 Jun 2010

ND

Added a bit more details to the -⁠o[ne_at_a_time] restore option to explain transactions.

1.2

24 Nov 2009

ND

Corrected the section on -⁠y Suppress_output plus corrected the formatting of various screen dumps.They had been reformatted as text at some point.

1.1

20 Oct 2009

ND

More minor updates and converted to a standalone manual.

1.0

10 Oct 2009

ND

Created as a chapter in the Command Line Utilities manual.

License notice

The contents of this Documentation are subject to the Public Documentation License Version 1.0 (the “License”); you may only use this Documentation if you comply with the terms of this License.Copies of the License are available at https://www.firebirdsql.org/pdfmanual/pdl.pdf (PDF) and https://www.firebirdsql.org/manual/pdl.html (HTML).

The Original Documentation is titled Firebird Backup & Restore Utility.

The Initial Writer of the Original Documentation is: Norman Dunbar.

Copyright © 2009-2013.All Rights Reserved.Initial Writer contact: NormanDunbar at users dot sourceforge dot net.

Contributor(s): Mark Rotteveel.

Portions created by Mark Rotteveel are Copyright © 2020-2024.All Rights Reserved.(Contributor contact(s): mrotteveel at users dot sourceforge dot net).