Backing Up and Restoring Using the ttBackup and ttRestore Utilities

When you use the ttBackup utility, it backs up the TimesTen database with all of its data at a particular time.

Thus, if you want to use these cache groups again, restoring this backup requires additional action as the restored data within the cache groups are out of date and out of sync with the data in the backend Oracle database. See Back Up, Restore, and Migrate Data in TimesTen Classic in the Oracle TimesTen In-Memory Database Installation, Migration, and Upgrade Guide.

Note:

See ttBackup and ttRestore in the Oracle TimesTen In-Memory Database Reference.

If the restored database connects to a different backend Oracle database than what it had originally connected with and you want to use the ttBackup and ttRestore utilities to backup and restore your database, then perform the following:

  1. Run the ttBackup utility command to backup the database and its objects into a binary file. For example, to backup the cache1 database using the /tmp/dump directory for temporary storage:

    % ttBackup -dir /tmp/dump -connstr "DSN=cache1"
  2. Stop the cache agent.

    % ttIsql -connstr "DSN=cache1;UID=cacheadmin;PwdWallet=/wallets/cacheadminwallet"
    Command> call ttCacheStop;
  3. (Optional) Drop all cache groups from the TimesTen database. Since the database still exists with its cache groups, TimesTen recommends that you drop the cache groups.

    Command> DROP CACHE GROUP readcache;
    Command> exit;
    Disconnecting...
    Done.
  4. Destroy the database before restoring in the same or another location.

    % ttDestroy cache1
  5. Clean up objects on the Oracle database. Run the timesten_home/install/oraclescripts/cacheCleanUp.sql SQL*Plus script from the current database install as the Oracle cache administration user to drop the Oracle Database objects used to implement autorefresh operations. The host name of the TimesTen Classic system and the TimesTen database (including its path) are passed as arguments to the cacheCleanUp.sql script.

    You can run the ttCacheInfo utility or the cacheInfo.sql script as the Oracle cache administration user to determine the host and database names.

    % cd timesten_home/install/oraclescripts
    % sqlplus cacheadmin/orapwd
    SQL> @cacheCleanUp "sys1" "/users/OracleCache/cache1"
    
    *****************************OUTPUT**************************************
    Performing cleanup for object_id: 69959 which belongs to table : CUSTOMER
    Executing: delete from tt_07_agent_status where host = sys1 and datastore =
    /users/OracleCache/cache1 and object_id = 69959
    Executing: drop table tt_07_69959_L
    Executing: drop trigger tt_07_69959_T
    Executing: delete from tt_07_user_count where object_id = object_id1
    Performing cleanup for object_id: 69966 which belongs to table : ORDERS
    Executing: delete from tt_07_agent_status where host = sys1 and datastore =
    /users/OracleCache/cache1 and object_id = 69966
    Executing: drop table tt_07_69966_L
    Executing: drop trigger tt_07_69966_T
    Executing: delete from tt_07_user_count where object_id = object_id1
    **************************************************************************
  6. Restore the database with the ttRestore utility and then delete the temporary directory.

    % ttRestore -dir /tmp/dump -connstr "DSN=cache1"
    Restore started ...
    Restore complete
    
    % rm -r /tmp/dump
  7. In order to re-synchronize the data within the cache groups, you must drop and recreate the cache groups:

    1. Connect to the TimesTen database providing the cache administration user credentials.

    2. Drop the cache groups that were restored with the ttRestore utility. Because the data is out of sync, you may see errors.

    3. Register the Oracle cache administration user name and password with the ttCacheUidPwdSet built-in procedure.

    4. Start the cache agent.

    5. Recreate and, if required, reload the cache groups.

    % ttIsql -connstr "DSN=cache1;UID=cacheadmin;PwdWallet=/wallets/cacheadminwallet"
    
    Command> DROP CACHE GROUP readcache;
    Command> call ttCacheUidPwdSet('cacheadmin','orapwd');
    Command> call ttCacheStart;
    Command> CREATE READONLY CACHE GROUP readcache
            AUTOREFRESH INTERVAL 5 SECONDS
            FROM sales.readtab
            (keyval NUMBER NOT NULL PRIMARY KEY, str VARCHAR2(32));
    Command> LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS;
    2 cache instances affected.

Note:

If the restored TimesTen database is not able to connect to any backend Oracle database, then TimesTen cannot autorefresh the data for the read-only cache groups.