Using Journal Archiving

From InterBase

Go Up to Journaling and Disaster Recovery

As mentioned on the previous section, a journal archive is a directory that contains a full database dump, and the completed journal files that have been archived since that dump. InterBase requires that you create and update archive content (the dump and journal files) in two steps:

1. Archive the database.
2. Archive the journal files.

The commands used to perform each task are explained below.

Note:
Creating a journal archive does not require exclusive database access.


The command that Activates Journal Archiving

The CREATE JOURNAL ARCHIVE command activates journal archiving in an InterBase database. A journal archive file (IB_JOURNAL_ARCHIVE) is placed in the journal archive directory.

Note:
To perform an initial (and subsequent) dumps, gbak -archive_database must be performed.

The following command is used to activate journaling:

CREATE JOURNAL ARCHIVE <journal archive directory>

where <journal archive directory> is the location in which InterBase stores the journal archive. If the directory does not exist or is not accessible, InterBase returns an error message. The directory path can be a local drive, a mapped drive, or an UNC path (as long as the underlying file APIs can open the file using that specification). If you do not specify a journal archive directory in the CREATE JOURNAL ARCHIVE statement, InterBase uses the journal directory created with the CREATE JOURNAL statement.

When you do not activate journal archiving, the current journal files are reused after a checkpoint writes the records of a jounal file to the hard drive.

Important:
You only use the CREATE JOURNAL ARCHIVE command to initiate journal archiving on a database. Once you initiate archiving and InterBase performs the first dump, you use the gbak -archive_database command, discussed below, to perform subsequent dumps. If you disable journal archiving and want to resume it, use CREATE JOURNAL ARCHIVE.


The Command that Archives Journal Files

The gbak -archive_journals command instructs InterBase to copy the completed journal files to the journal archive directory. To ensure that the archive always contains the most recently completed journal files, you should issue this command on a regular basis.

To copy completed journal files to the archive directory, use the following syntax:

gbak -archive_journals <dbname>

where <dbname> specifies the database that is being archived. The journal archive will grow in storage size as the most recently completed journal files are continually archived. For instructions on how to manage archive size, see Managing Archive Size.

The Command that Performs Subsequent Archive Dumps

After the initial dump, performed by the CREATE JOURNAL ARCHIVE command, you use the following syntax to perform subsequent dumps:

gbak -archive_database <dbname>

This command performs a full, physical dump to the archive directory, which helps to reduce the number of journal files that must be stored. The older a dump is, the more journal files InterBase needs to keep the archive up-to-date.


How Often Should you Archive Journal Files?

Use the following statements and questions to help determine how often to archive journal files:

  • How much data can you afford to lose if the IB server is destroyed?
  • What is the journal rollover frequency? There is no reason to archive journal files more often that the journal rollover interval.
  • Frequent journal rollover + frequent journal archiving means minimum data loss. However, too frequent journal rollover + too frequent journal archiving means poor performance. What is the best balance for your system?


Disabling a Journal Archive

The DROP JOURNAL ARCHIVE statement disables journal archiving for the database. It causes all journal files and database file dumps to be deleted in all journal archive directories. The file system directories themselves are not deleted.

Disabling journal archiving does not disable database journaling (the creation of journal files). The database will continue to use the write-ahead protocol to commit database changes to the journals. If the intent is to also disable journaling, then you must execute a separate DROP JOURNAL statement, shown in Disabling Journal Files.

To disable journal archiving, use the following syntax:

DROP JOURNAL ARCHIVE

Advance To: