Restoring a database with gbak

From InterBase

Go Up to Performing backups and restores using the gbak command


Note:
For information on restoring tablespaces refer to Tablespace Backup/Restore and Recovery

Use the following syntax to restore a database:

For restoring:

gbak {-c|-r} [options] source dbfile

For restoring to multiple files:

gbak {-c|-r} [options] source dbfile1 size1 dbfile2 [size2 dbfile3 …]

For restoring from multiple files:

gbak {-c|-r} [options] source1 source2 [source3 …] dbfile

By extension, you can restore from multiple files to multiple files using the following syntax:

gbak {-c|-r} [options] source1 source2 [source3 …] dbfile1 size1
 dbfile2 [size2 dbfile3 …]

For restoring from Embedded User Authentication backup files:

The USER and PASSWORD server credentials are required to create a database on the server and execute the restore service. The -eua_u[ser] name and -eua_p[assword] text database credentials are required to ensure that only the database owner can restore an EUA database.

Restoring a Database with gbak
Argument Description

<source>

Name of a storage device or backup file from which to restore.

On UNIX, this can also be stdin, in which case gbak reads input from the standard input (usually a pipe).

<dbfile>

The name of a restored database file.

<size>

Length of a backup file or restored database file

  • The only permissible unit for a restored database file is database pages; minimum value is 200.
  • Default unit for a backup file is bytes.
  • Size of backup files can also be specified in kilobytes, megabytes, or gigabytes.
  • Do not specify a size for the final backup file or database file; the last file always expands as needed to fill all available space.

The following table lists gbak options that are available when restoring databases.

gbal Restore Options
Option Description

-c[reate_database]

Restores database to a new file.

-bu[ffers]

Sets cache size for restored database.

-i[nactive]

Makes indexes inactive upon restore.

-eua_u[ser] name

Checks for user name before accessing EUA (embedded user authentication) database.

The -user and -password options still need to be provided, in addition to your -eua equivalents when restoring an EUA database.

Either EUA switch can be omitted if it has an identical value to its counterpart. However it is recommended that the PASSWORD and EUA_PASSWORD should not be the same.

-eua_p[assword] text

Checks for password text before accessing EUA (embedded user authentication) database.

The -user and -password options still need to be provided, in addition to your -eua equivalents when restoring an EUA database.

Either EUA switch can be omitted if it has an identical value to its counterpart. However it is recommended that the PASSWORD and EUA_PASSWORD should not be the same.

-k[ill]

Does not create any shadows that were previously defined.

-mo[de] {read_write | read_only}

Specifies whether the restored database is writable

  • Possible values are read_only and read_write.
  • Default is read_write.

-n[o_validity]

Deletes validity constraints from restored metadata; allows restoration of data that would otherwise not meet validity constraints.

-ods[_version] n

Restores the database to specific major ODS version number. where <n> is a supported major ODS version. The target database engine will have its own allowed major ODS version list. When this option is specified at restore time, it overrides the server-side IBConfig setting DATABASE_ODS_VERSION.

  • gbak -r employee.gbk emp15.ib -ods_version 15 -user sysdba -pass masterkey
  • gbak -c employee.gbk emp17.ib -ods_version 17 -user sysdba -pass masterkey
  • gbak -service localhost:service_mgr -r <path>/employee.gbk <path>/emp17.ib -ods_version 17 -user sysdba -pass masterkey

-o[ne_at_a_time]

Restores one table at a time; useful for partial recovery if database contains corrupt data.

-p[age_size] n

Resets page size to <n> bytes (1024, 2048, 4096, 8192, or 16384); default is 4096.

-pas[sword] text

Checks for password <text> before accessing a database.

-r[eplace_database]

Restores database to new file or replaces existing file.

-se[rvice] servicename

  • Creates the restored database on the host where the backup files are located, using InterBase Service Manager.
  • <servicename> invokes the Service Manager on the server host; syntax varies with the network protocol in use:
TCP/IP hostname:service_mgr
Named pipes \\hostname\service_mgr
Local service_mgr

-user name

Checks for user <name> before accessing database.

-use_[all_space]

Restores database with 100% fill ratio on every data page. By default, space is reserved for each row on a data page to accommodate a back version of an UPDATE or DELETE. Depending on the size of the compressed rows, that could translate e to any percentage.

-v[erbose]

Shows what gbak is doing.

-va[lidate]

Use to validate the database when restoring it.

-w[rite] {async | sync | direct}

Overrides a database write mode. The “write” mode is preserved during a backup/restore lifecycle.

sync enables forced writes; async enables buffered writes; direct enables direct I/O.

-y [file | ­suppress_output]

If used with -v, directs status messages to <file>; if used ­without -v and <file> is omitted, suppresses output messages.

-z

Show version of gbak and of InterBase engine.

When restoring a database, keep the following information in mind:

  • Anyone can restore a database. However, only the database owner or SYSDBA can restore a database over an existing database.
  • Do not restore a backup over a database that is currently in use; it is likely to corrupt the database.
  • When restoring from a multifile backup, name all the backup files, in any order.
  • Do not provide a file size for the last (or only) file of the restored database. InterBase does not return an error, but it always “grows” the last file as needed until all available space is used. This dynamic sizing is a feature of InterBase.
  • You specify the size of a restored database in database pages. The default size for database files is 200 pages. The default database page size is 4K, so if the page size has not been changed, the default database size is 800K. This is sufficient for only a very small database. To change the size of the database pages, use the -p[age_size] option when restoring.
Tip:
Use the -service switch if you are restoring to the same server that holds the backup file. This option invokes the InterBase Service Manager on the server host and saves both time and network traffic.
Note:
If you specify several target database files but have only a small amount of data, the target files are quite small (around 800K for the first one and 4K for subsequent ones) when they are first created. They grow in sequence to the specified sizes as you populate the database.


Advance To: