Backing Up and Restoring a Database
The ability to backup and restore a database in TimesTen Classic is essential to protect your data. It is recommended that you perform regular backups to minimize the risk of potential data loss.
Use the ttBackup and ttRestore utilities to perform backup and restore procedures. See ttBackup and ttRestore in Oracle TimesTen In-Memory Database Reference for details. You can only run these utilities to backup and restore a database when:
-
The first two digits of the version of the utility matches the first two digits of the version of the database and
-
The platform of the utility matches the platform of the database
See Overview of Release Numbers for information on the format of release number.
Note:
You cannot use these utilities in a client-only environment.
Relevant information in this section include:
Backup Features
Every database backup contains the information needed to restore the database as it existed at the backup point, which is the time the backup began. Restoration of a database from a given backup restores the modifications of all transactions that committed before the backup point.
A backup operation is atomic. If it completes successfully, it produces a backup you can use to restore a database to the state of its backup point. See ttBackup in the Oracle TimesTen In-Memory Database Reference for more information.
Note:
-
Do not manually change the contents of the backup directory. The addition, removal, or modification of any file in the backup directory, except for modifications made by
ttBackup
andttRestore
, may compromise the integrity of the backup. In this event, restoration of the database from the backup may not be possible. -
Databases containing cache groups can be backed up with the
ttBackup
utility. However, when restoring such a backup, special consideration is required. The restored data within the cache groups may be out of date or out of sync with the data in the back-end Oracle database. To restore a database that contains cache groups, see Backing Up and Restoring a TimesTen Classic Database with Cache Groups in the Oracle TimesTen In-Memory Database Cache Guide for more information.
Types of Backups
TimesTen Classic supports these types of backups.
-
Full: A full backup contains the most recent consistent checkpoint file and all the existing transaction log files. This backup saves the entire database. For full backups, ensure you have enough disk space available to hold both the existing backup and the new backup. A full backup can be a stream backup. A stream backup writes the database backup file to
stdout
. -
Incremental: An incremental backup moves the backup point of an existing backup forward in time by augmenting the backup with all the transaction log records created from the most recent incremental or full file incremental-enabled backup. An incremental backup moves the backup point of an existing backup forward in time by augmenting the backup with all of the transaction log records created since its last backup point.
An incremental backup typically completes faster than a full backup, as it has less data to copy. The performance gain of incremental backups over full backups comes at the cost of increased disk usage and longer restoration times. Use incremental backups in concert with full backups to achieve a balance between backup time, disk usage, and restoration time. Incremental backups hold transaction logs, so you should run incremental backups regularly.
Before you can perform an incremental backup, you must enable your backup to allow for incremental backups by running the
ttBackup
utility with the-fileFullEnable
or the-fileIncrOrFull
options. In either case, if your backup was not previously enabled for incremental, a full file backup is performed before the backup is enabled for subsequent incremental backups. TimesTen Classic supports the creation of up to eight incremental-enabled backup instances for each database. If you attempt to start a ninth incremental backup, TimesTen Classic returns an error.If you restore a database from a backup, regardless of whether the backup was enabled or disabled for incremental, the restored database is disabled for incremental backups. To enable incremental backups, you must again run the
ttBackup
utility with the-fileFullEnable
or the-fileIncrOrFull
.
A set of files containing backup information for a given database, residing at a given backup path, is known as a backup instance. A given backup instance must be explicitly enabled for incremental backups.
The list of backup types supported by TimesTen Classic are included in this table. See ttBackup in the Oracle TimesTen In-Memory Database Reference for more information:
Backup type | File or stream | Full or incremental | Incremental-enabled | Comment |
---|---|---|---|---|
|
File |
Full |
No |
Default |
|
File |
Full |
Yes |
Full backup and resulting backup enabled with incremental backup |
|
File |
Incremental |
Yes |
Fails if incremental backup is not possible |
|
File |
Either |
Yes |
Performs |
|
Stream |
Full |
No |
Stream backup |
|
None |
None |
No |
Does not perform a backup and disables incremental backups. Prevents transaction logs files from accumulating. |
Restoring a Database
Run the ttRestore
utility to restore a database backup previously created with the ttBackup
utility. See ttRestore in the Oracle TimesTen In-Memory Database
Reference for details on this utility.
Note:
You can alternatively use corresponding C functions for ttBackup
and ttRestore
. See TimesTen Utility API in Oracle TimesTen In-Memory Database C Developer's
Guide for more information.
Backup and Restore Examples
You can backup and restore a database to a different directory on the same host. You can also backup and restore a database on a different host of the same platform type.
Examples:
Performing a Simple Backup and Restore
This example backs up the database1
database to the /scratch/backup
directory. It then runs ttDestroy
to delete the database. (ttRestore
returns an error if you try to overwrite an existing database.) Finally, it runs ttRestore
to restore the database1
database.
% ttBackup -dir /scratch/backup database1 Backup started ... Backup complete % ttDestroy database1 % ttRestore -dir /scratch/backup database1 Restore started ... Restore complete
Moving a Database to a Different Directory
The TimesTen daemon identifies a database by the full path name of the database checkpoint files. To move a database to a different directory, back up the database using the ttBackup
utility, create a new DSN definition that specifies the new database path name, then restore the database into its new location using the ttRestore
utility.
This example moves a database from /scratch/old/database1
with a database name database1
to /scratch/new/database1
with database name database1_new
, using the /scratch/tmp
directory for temporary storage.
Moving a Database to a Different Host (Same Platform)
You can use the ttBackup
and ttRestore
utilities to move a database between two hosts that have the same major release of TimesTen Classic, the same CPU architecture, and the same operating system.
To copy a database from one host to another with the same CPU architecture and operating system: