gbak caveats

<< Backup & restore recipes | Firebird Backup & Restore Utility | A. Document history >>

gbak caveats

The following is a brief list of gotchas and funnies that I have detected in my own use of gbak. Some of these are mentioned above, others may not be. By collecting them all here in one place, you should be able to find out what's happening if you have problems.

gbak default mode

If you do not specify a mode switch such as -b[ackup] or -c[reate] etc., then gbak will perform a backup as if the -b[ackup] switch had been specified - provided that the other switches specified are correct for a backup.

Warning: This detection of whether you are attempting a backup or a restore means that if you use the -z command line switch to view gbak information, then you will create a backup - and overwrite the backup file you supply - if the command line also has a database name and a backup file name present. This assumes that there is a way for gbak to deteremine the username and password to be used - either as command-line parameters or via defined environment variables.

Normal versus privileged users

Only a SYSDBA or the owner of a database can take a backup of the database, however, any authenticated user can restore a database backup using the -c[reate] switch. This means that you must make sure you prevent your backup files from falling into the wrong hands because there is nothing then to stop unauthorised people from seeing your data by the simple process of restoring your backups onto their server.

The database restore will fail, of course, if the user carrying it out is not the database owner and a database with the same filename already exists.

back to top of page

Silent running?

The -y suppress_output switch is supposed to cause all output to be suppressed. Similar in fact to running with -v[erify] not specified. However, all it seems to do is cause the output (according to the -v[erify] switch setting) to be written to a file called suppress_output, however this only works once because the next run of gbak with -y suppress_output will fail because the file, suppress_output, already exists.

It is possible that this problem was introduced at version 2 for Firebird, because both 2.0 and 2.1 versions actually use the -y suppress switch rather then -y suppress_output. Using this (shorter) option does work as intended and the output is indeed suppressed.

gbak log file cannot be overwritten

If you specify a log file name 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 dump and logfile name.
 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.

back to top of page

Use of stdin or stdout file names

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 file names 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 file names, 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 dump 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 file name rather than a special file name that causes different to normal processing during the dump or restore process.

back to top of page
<< Backup & restore recipes | Firebird Backup & Restore Utility | A. Document history >>