5 Backup, Restore, and Migrate Data in TimesTen Classic

This chapter describes the processes for backing up and restoring your database and for migrating the data in your database in TimesTen Classic.

This chapter is only relevant for TimesTen Classic. For information on the backup, restore, and migration processes for a database in TimesTen Scaleout, see "Migrating, Backing Up and Restoring Data" in the Oracle TimesTen In-Memory Database Scaleout User's Guide. For information on migrating a database from TimesTen Classic to TimesTen Scaleout, see "Migrating a database from TimesTen Classic to TimesTen Scaleout" in the Oracle TimesTen In-Memory Database Scaleout User's Guide.

Topics in this chapter include:

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.

Notes:

  • 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 and ttRestore, 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 database with cache groups" in the Oracle TimesTen Application-Tier Database Cache User's 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
fileFull File Full No Default
fileFullEnable File Full Yes Full backup and resulting backup enabled with incremental backup
fileIncremental File Incremental Yes Fails if incremental backup is not possible
fileIncrOrFull File Either Yes Performs fileIncremental if possible, or fileFullEnable otherwise
streamFull Stream Full No Stream backup
incrementalStop 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.

  1. Create a temporary directory.

    % mkdir /scratch/tmp
    
  2. Disconnect applications from the database.

  3. Back up the database to the temporary directory

    % ttBackup -dir /scratch/tmp -fname database1 database1
    Backup started ...
    Backup complete
    
  4. Unload the database from memory. See "Unloading a database from memory" for information.

  5. Create a new DSN, named database1_new and set the DataStore attribute to the full database path name of the database and the file name prefix:

    [database1_new]
    DataStore=/scratch/new/database1/database1_new
    
  6. Restore the backup in the new location.

    % ttRestore -dir /scratch/tmp -fname database1 database1_new
    Restore started ...
    Restore complete
    
  7. Remove the temporary directory.

    rm -r /scratch/tmp
    
  8. After you confirm the database is operational in the new location, optionally, run the ttDestroy utility to destroy the database in the old location, and then delete the old DSN.

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:

  1. Disconnect applications from the database.

  2. Back up the database on the original host using ttBackup.

    %ttBackup -dir /scratch/tmp -fname database1 database1
    Backup started ...
    Backup complete
    
  3. Move the backup to the new host.

  4. Create a DSN for the database on the new system. See "Creating a DSN on Linux and UNIX for TimesTen Classic" in the Oracle TimesTen In-Memory Database Operations Guide for more information.

  5. Restore the backup on the new system using ttRestore.

    % ttRestore -dir /scratch/tmp -fname database1 database1_new
    Restore started ...
    Restore complete
    
  6. After the database is operational on the new host, you can use the ttDestroy utility to destroy the database on the old host, and you can then delete the old DSN.

Migrating a database

You can migrate your database from one major release of TimesTen Classic (such as 11.2.2) to another major release of TimesTen Classic (such as 18.1). You run the ttMigrate utility to achieve this. ttMigrate saves database objects in a binary file and upgrades or downgrades database objects by restoring the objects from the binary file into the target database.

The binary files are platform-dependent. For example, a binary file produced on Linux must be restored on Linux. However, you can use the ttMigrateCS utility to copy a database between platforms (for example, between Linux and UNIX).

For more information, see "ttMigrate" in the Oracle TimesTen In-Memory Database Reference.

Note:

This section discusses the migration of databases in TimesTen Classic. For information on migrating databases from TimesTen Classic to TimesTen Scaleout and on migrating databases in TimesTen Scaleout, see "Migrating, Backing Up and Restoring Data" in the Oracle TimesTen In-Memory Database Scaleout User's Guide.

Examples using ttMigrate include:

Moving to a different major release of TimesTen Classic

In TimesTen Classic, you can migrate data between major releases (for example, from TimesTen 11.2.2 to 18.1) by using the ttMigrate utility to export the data from the old release and import it to the new release.

Prerequisites before migrating a database from one major release to another:

Follow these steps:

  1. On the old release, disconnect all applications from your database.

  2. Save a copy of your database with the ttMigrate utility.

    % ttMigrate -c database1 /tmp/database1.data
    ...
    

    For more information about the ttMigrate utility, see "ttMigrate" in the Oracle TimesTen In-Memory Database Reference.

  3. In the old release, unload the database from memory. See "Unloading a database from memory" for details.

  4. In the old release, if necessary, use the ttDestroy utility to destroy the old database. This step is required if the new database will be in the same location as the old database.

  5. Copy the migrate object files to a file system that is accessible by the instance in the new release.

  6. From the instance of the new release, create a database. Ensure that you have modified the connection attributes in the sys.odbc.ini (or odbc.ini) file and that you have sourced the environment variables and started the daemon.

    To create the database:

    % ttIsql -connstr "dsn=new_database1;AutoCreate=1" -e "quit"
    

    The database will be empty at this point.

  7. From the instance of the new release, use ttMigrate with the -r and -relaxedUpgrade options to restore the backed up database to the new release. For example:

    % ttMigrate -r -relaxedUpgrade new_database1 /tmp/database1.data
    

Once the database is operational in the new release, create a backup of this database to have a valid restoration point for your database. Once you have created a backup of your database, you may delete the ttMigrate copy of your database (in this example, /tmp/database1.data). You can also delete the instance and installation from the old release.

Moving a database to a different platform

The internal format of a database differs between platforms. You can use this procedure to move a database from one platform to another, such as from AIX to Linux, and reformat it for the target platform.

  1. Disconnect applications from the database.

  2. From the target system, use ttMigrateCS to connect in client/server mode to the database on the originating system and use the -c option to create a data file for the database on the target system. For example:

    ttMigrateCS -c database1 database1data.dat
    ...
    
  3. On the target system, create a DSN for the database. See "Creating a DSN on Linux and UNIX for TimesTen Classic" in the Oracle TimesTen In-Memory Database Operations Guide for information.

  4. Confirm that all connection attributes, including the DataStore connection attribute, are set correctly for the location on the new system.

  5. Recreate the database using AutoCreate=1, such as in the following example:

    ttIsql -connstr "dsn=database2;AutoCreate=1" -e "quit"
    

    The database will be empty at this point.

  6. On the target system, import the file created by ttMigrateCS into the new database using the ttMigrate utility with the -r option and the -relaxedUpgrade option. For example:

    ttMigrate -r -relaxedUpgrade database2 database1data.dat
    
  7. As desired, once the database is operational on the new system, use the ttDestroy utility to destroy the database on the old system, and delete the old DSN.