Recovery from Checkpoints
To recover a database from checkpoints and journals or from checkpoints only, you use the roll forward operation. This operation lets you recover the following:
• A non-journaled database from a checkpoint
• A journaled database from checkpoints and journals
• A database from a tape checkpoint
How the Roll Forward (Restore) Operation Works
Performing a roll forward of a database overwrites the current contents of the database being recovered.
To perform a roll forward, you must be the DBA for the database or have the operator privilege.
When you roll forward (restore) a database, the database is locked to prevent errors from occurring. If the database is busy, the roll forward operation waits for the database to be free before recovering it. (If you specify the wait [+w] option, the rollforwarddb operation pauses until all users have left the database. If you do not specify the wait option, you get a message that the database is in use.)
If the target checkpoint was taken online (when the database was in use), the roll forward operation does the following:
• Restores the database from the checkpoint location to the database location.
• Applies the log records in the dump location to the database, which restores the database to the state when the checkpoint began. The log records contain the transactions that were in progress when the checkpoint was taken.
This step is not performed when restoring a database from an offline checkpoint because there were no transactions in progress during an offline checkpoint.
• Applies the journal records to the database.
Limitations to Rollforward Operation
The rollforwarddb (restore) operation in Vector does not support the following:
• Restoring the database online. All restore operations must be done when no one is using the database.
• Restoring the database to a point in time, and then restoring more journals to the next point in time.
Note: In VectorH, you must be the instance owner to use ckpdb and rollforwarddb commands.
Tools for Performing a Roll Forward
The system command to roll forward a database is rollforwarddb.
In Actian Director, use the Restore operation.
Recover a Database with rollforwarddb
Performing a roll forward (restore) of a database overwrites the current contents of the database being recovered. To perform a roll forward, you must be the DBA for the database or have the operator privilege.
The roll forward operation restores the database from the checkpoint location to the database location.
IMPORTANT! After Vector is upgraded, do not issue the rollforwarddb command using checkpoints from earlier versions of Vector. Such an operation is not supported. The upgrade process changes the database structure. Using the older checkpoints will cause the database to become inconsistent, and extra steps will be required to restore the database to a usable state. We recommend that you checkpoint (back up) your databases as soon as they are upgraded.
To recover a database from the last checkpoint and journal
Issue the following command at the operating system prompt:
rollforwarddb dbname
Note: Upon restart, the database will be in the same state it was when you took the checkpoint.
To recover a database from an old checkpoint
1. Issue the infodb command to see the list of valid checkpoints:
infodb dbname
2. Recover the database from the specific checkpoint:
rollforwarddb '#cn' dbname
where n is the checkpoint sequence number.
Recover a Journaled Database
To recover a specific database from the last checkpoint and journal, where both the checkpoints and journals are stored online, issue the following command at the operating system prompt:
rollforwarddb dbname
Note: All journals since the last checkpoint must be present.
Recover a Non-Journaled Database
To recover a non-journaled database from the last checkpoint, issue the following command from the operating system prompt:
rollforwarddb +c dbname
Recover a Database from Tape Checkpoints
To recover a database whose checkpoints are on tape
1. Mount the tape reel containing the checkpoints.
2. Issue a rollforwarddb command at the operating system prompt, naming the tape drive as the device:
rollforwarddb +c +j -mdevice dbname
The checkpoint is read from the tape and the journal files are applied, if the database is journaled, to bring your database up to date.
Recover a Database from an Old Checkpoint
If the most recent checkpoint has been damaged or is unreadable, it is possible to recover from an older checkpoint. You can use either a specific checkpoint number or the most recent usable checkpoint.
To recover the database from a checkpoint and apply all journals after that time, issue the following command:
rollforwarddb +j '#cn' dbname
where n is the checkpoint number. For example, the following command requests recovery from checkpoint 4 for the Employee database:
rollforwarddb +j #c4 employee
The checkpoint sequence number must be a valid checkpoint number. You can verify this number with the infodb command.
If the most recent checkpoint is unfinished and you want to recover using the most recent usable finished checkpoint, issue the following command:
rollforwarddb +j '#c' dbname
Recover from the Loss of the Transaction Log File
In the unlikely event of a loss of the transaction log file (or, if dual logging is enabled, loss of both file copies), the following recovery procedure can be used to restore as much database information as is possible. Follow these steps:
1. Create a new transaction log file. For more information, see the Getting Started guide.
2. The next action differs, depending on whether offline or online backups take place. Included in the latter class of systems are those that employ journaling capabilities.
• For offline backups
Installations using their own backup and recovery mechanisms (implying no use of online checkpoint or journaling facilities) only need to restore database directories and bring the system back up. No directed recovery is needed, after backups are done during a period when there is no system activity, and when all database information is resident on disk.
• For online backups and roll forward
If you are using online checkpoints and journaled databases, bring the installation back up with the newly initialized log file. All databases open at the time of the failure can be marked inconsistent by the recovery process. Each must be recovered in turn by the roll forward database operation. The +j (Enable Journaling) option with roll forward is specified for journaled databases; this option is not specified for those databases that are not journaled.
Note: A roll forward operation restores databases to a consistent state even if incomplete transaction histories have been copied to the journal files.
Backup and Recovery of the Master Database (iidbdb)
The iidbdb database is the master database for the installation. It contains information about your installation, such as:
• Which databases exist in this installation
• Where user databases are located
• Which locations can be used for files
• Which users can access databases
The iidbdb also contains information about groups, roles, and database privileges defined for your site.
The iidbdb is journaled by default.
The iidbdb and Checkpointing
You should regularly checkpoint and journal the iidbdb database. Ckpdb and rollforwarddb are the supported utilities for recovering the iidbdb if it is lost or damaged for any reason. The system catalogs containing the installation information for groups, roles, and database privileges are stored in the iidbdb database and can only be recovered from backups.