To invoke gbak, either cd to the Firebird /bin directory where gbak is located or use an absolute root path. The entire command must be on a single line. In the following syntax patterns and examples, the wrapped portions of lines are shown as indented. POSIX:$] ./gbak -b[ackup] <options> source target [n]
or$] /opt/firebird/bin/gbak -b[ackup] <options> source target [n]
Windows:C:Program FilesFirebirdFirebird_1_5in> gbak -b[ackup]<options> source target [n]
orC:> C:Program FilesFirebird_1_5ingbak -b[ackup]<options> source target [n]
Arguments for gbak –b[ackup]
source is the full path and file name of a database to back up. In Firebird 1.5, it can be an alias. If backing up a multi-file database, use only the name of the first (primary) database file.
target is the full path and file name of a storage device or backup file to which the backed-up database is to be sent.
In the case that the backup is being output to multiple files, there will be multiple targets. The token n is an integer parameter, included with each output file except the last, to indicate the length of the file in (by default) bytes. A lowercase character can be appended to the number to specify that size is in kilobytes (k), megabytes (m), or gigabytes (g). Refer to the examples that follow.
On POSIX, target can also be stdout. In this case, gbak writes its output to the standard output (usually a pipe).
options can be a valid combination of switches from Table. The switches are case insensitive.
Table lists and describes the switches that can be used with gbak when running backups.
gbak Switches for Backups
Accept the default –transportable switch if you operate in a multi-platform environment.
It writes data in the cross-platform standard eXternal Data Representation (XDR)3 format, allowing the file to be read by the gbak program on a platform different from the one on which it was backed up.
The gbak program on servers with lower ODS than the Firebird server that created a database will generally not be able to restore from the higher ODS backup. In practice, however, the InterBase 5.x version of gbak appears to be capable of restoring most dialect 1 databases created with Firebird 1.0.x.
Backing Up to a Single File
For a simple local backup of a single-file or multiple-file database, usegbak -b d:dataourdata.fdb d:dataackupsourdata.fbk
The source name is the same whether the database you are backing up is a single or a multiple-file database. When you are backing up a multi-file database, specify only the first file in the backup command. The paths to the second and subsequent files will be found by gbak in the database and file headers during the course of the backup. If you name the subsequent database files, they will be interpreted as backup file names.
The target file can have any name you wish, as long as it is valid on the filesystem to which it is being written.
Backing Up a Multi-file Database to Multiple Files
When you back up a multi-file database to multiple gbak files, there is no requirement to match the database file for file with the backup. If there is to be more than one target file, the names and sizes of the target files need to be specified for all except the last file in the set. By default, the file size (an integer) is taken to be in bytes. To modify that, append a lowercase character to tell gbak you intend the size to be in kilobytes (k), megabytes (m), or gigabytes (g).
The following command backs up a database to three backup files on different filesystem partitions and writes a verbose log. It is all one command; the indented portions are wrapped here for easier reading.
POSIX:./gbak -b /data/accounts.fdb /backups/accounts.fb1 2g
Single-File Database to Multiple Targets
If you back up a single-file database to multiple targets, the syntax is identical. In fact, gbak is not interested in whether your source database is single- or multiple-file.
It is important to note the following points:
A metadata-only backup is typically needed for creating an “empty” database when you are ready to deploy a system into production, load QA data, or reconstitute a database for the purpose of migrating. The following command does a metadata-only backup of our accounts database:gbak -b -m d:dataaccounts.fdb e:QAaccounts.fbk
If you run gbak from a remote client machine, it writes the backup files to the current directory or to a specified, fully qualified local path. If you specify a location for the backup file, it must be accessible by the machine where gbak is executing. The location can be any of the following:
With the –se[rvice] switch, you can invoke the Firebird Service Manager on the remote server and have gbak delegate the execution of your command on the server itself. The database and backup file specifications must then refer to a location and file name local to the server machine. Locations local to where gbak is launched are not valid for a Service Manager backup. For more about Service Manager, see the upcoming section “Using gbak with the Firebird Service Manager.”
It is a good precaution to set the read-only property on your backup files at thefilesystem level after creating them, to prevent them from being accidentally or maliciously overwritten.
You can protect your databases from being “kidnapped” on UNIX and on Windows NT/ 2000/ XP systems by placing the backup files in directories with restricted access.
Return Codes and Feedback
A backup run on Windows returns an error level of 0 on success and 1 on failure. If an error occurs, check the firebird.log file (interbase.log in v.1.0.x). For a full backup log file, use the –y and –v switches.
Firebird Related Interview Questions
|RDBMS Interview Questions||MySQL Interview Questions|
|Linux Interview Questions||Mac OS X Deployment Interview Questions|
|Windows Administration Interview Questions||Windows Server 2003 Interview Questions|
|SQL Interview Questions||NoSQL Interview Questions|
|Advanced C++ Interview Questions|
Introduction To Client/server Architecture
About Firebird Data Types
Date And Time Types
Blobs And Arrays
From Drawing Board To Database
Creating And Maintaining A Database
Firebird’s Sql Language
Expressions And Predicates
Querying Multiple Tables
Ordered And Aggregated Sets
Overview Of Firebird Transactions In
Programming With Transactions
Introduction To Firebird Programming
Developing Psql Modules
Error Handling And Events
Security In The Operating Environment
Configuration And Special Features
Interactive Sql Utility (isql)
Database Backup And Restore (gbak)
Housekeeping Tool (gfix)
Understanding The Lock Manager
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.