Point-in-time recovery

Recovering data to a prior time is a point-in-time recovery. You can recover objects to a particular RBA, LRSN, or image copy. You can do this type of recovery by using the RECOVER utility point-in-time recovery options. These options are TOCOPY, TOLOGPOINT, TOLASTCOPY, TORBA, and TOLASTFULLCOPY.

You can recover objects to any RBA or LRSN by using TORBA or TOLOGPOINT. You can recover objects to a previous image copy by using TOCOPY, TOLASTCOPY, or TOLASTFULLCOPY.

When you recover objects to an RBA or LRSN, the RBA or LRSN does not have to be a consistent point in time. The RECOVER utility automatically handles any uncommitted units of work and the data is left in a consistent state.

When you recover objects to an image copy, whether the image copy is a consistent point in time depends on the type of image copy. An image copy that was taken with SHRLEVEL REFERENCE is a point of consistency. An image copy that was taken with SHRLEVEL CHANGE is not an explicit point of consistency.

Another explicit point of consistency is a quiesce point, which is a point at which data is consistent as a result of running the DB2® QUIESCE utility.

Recoveries to a consistent point in time are the most efficient because no uncommitted units of work need to be backed out.

Recommendation: If you use the RECOVER utility to recover data to an image copy by specifying TOCOPY, TOLASTCOPY, or TOLASTFULLCOPY, specify a copy that was made with the SHRLEVEL REFERENCE option.

To achieve consistency when you want to recover to a copy that was taken with SHRLEVEL CHANGE, specify a recovery point immediately after the copy completed. To find this point, locate a record for the SHRLEVEL CHANGE copy in SYSIBM.SYSCOPY and use the value in the PIT_RBA column. Specify that recovery point by using the TORBA or TOLOGPOINT options in the RECOVER statement.

You do not need to take a full image copy after you recover data to a point in time, except in the case of fallback recovery. DB2 records the RBAs or LRSNs that are associated with the point-in-time recovery in the SYSIBM.SYSCOPY catalog table to allow future recover operations to skip the unwanted range of log records.

If you specify the TOCOPY, TOLASTCOPY, or TOLASTFULLCOPY option to recover data to a point in time, RECOVER puts any associated index spaces in REBUILD-pending status. If you specify the TOLOGPOINT or TORBA option to recover data to a point in time, RECOVER puts any associated index spaces in REBUILD-pending status if the indexes are not recovered in the same RECOVER statement as their corresponding table space. The reason is that a point-in-time recovery of only the table space leaves data in a consistent state and indexes in an inconsistent state.

Start of changeYou can remove the REBUILD-pending state in one of the following ways:End of change

Start of change
  • Run REBUILD INDEX on the indexes.
  • Run RECOVER to a point in time on the indexes. If you do that, DB2 sets the CHECK-pending state on the indexes, because the table space was not recovered in the same RECOVER utility statement as the indexes.
End of change

If you use a point-in-time recovery option to recover a single data set of a nonpartitioned table space, DB2 issues message DSNU520I to warn that the table space can become inconsistent following the RECOVER job. This point-in-time recovery can cause compressed data to exist without a dictionary or can even overwrite the data set that contains the current dictionary.

If you use the point-in-time recovery option to recover a partition-by-growth table space that has an image copy with fewer partitions than the current table space, any excess partitions (partitions that are currently defined but not in the image copy) are empty after the RECOVER processing.

If a table space or partition in reordered row format is recovered to a point in time when the table space or partition was in basic row format, the table space or partition reverts to basic row format after RECOVER processing. Similarly, if a table space or partition in basic row format is recovered to a point in time when the table space or partition was in reordered row format, the table space or partition revert to reordered row format after RECOVER processing.

After recovering a set of table spaces to a point in time, you can use CHECK DATA to check for inconsistencies.

If you use the RECOVER utility to recover a table space set to a point-in-time, you must ensure that you recover the entire set of table spaces to the same point in time. If you do not include every member of the set, or if you do not recover the entire set to the same point in time, RECOVER sets the auxiliary CHECK-pending status on for all table spaces in the set.

You can also use point-in-time recovery and the point-in-time recovery options to recover all user-defined table spaces and indexes that are in refresh-pending status (REFP).

Recommendation: After running any point-in-time recoveries, run REORG TABLESPACE and REBUILD INDEX to set the real-time statistics. For more information about the effect of point-in-time recoveries on real-time statistics, see Effects of running RECOVER.
Requirement: To use system-level backups as a recovery base, DFSMShsm must be at z/OS® 1.8 or higher.
Start of change

Backing out work to a point-in-time

The RECOVER utility can recover your data to a point in time by backing out committed work from the current state of the data. To recover data by backing out, specify BACKOUT YES on the RECOVER control statement.

In some circumstances, recovering to a point in time by backing out work can be faster than recovering to a point in time by restoring a copy of the data and applying the logs forward.

When the RECOVER utility performs a point-in-time recovery by backing out committed work, the recovery is a point-in-time recovery with consistency, because any work that was uncommitted at the point in time to which the data is being recovered is also backed out. When the recovery is complete, the data is left in a transaction consistent state.

Restrictions: You cannot perform a backout recovery to the following points in time:
  • A point in time that is earlier than the timestamp of the latest SQL ALTER record in SYSIBM.SYSCOPY for the object being recovered.
  • A point-in-time that is earlier than the completion time of a previous backout recovery.
  • Start of changeA point-in-time before a utility that inserts SYSCOPY records was run, unless the utility is COPY or COPYTOCOPY.End of change
  • Start of changeA point-in-time before REORG TABLESPACE with the LOG(YES) option was run on the table space.End of change

Before running the RECOVERY utility with the BACKOUT YES option, run the REPORT utility with the RECOVER option on the object being recovered to identify events that might prevent you from recovering the object by backing out work to a given point in time.

End of change

Recovery considerations after rebalancing partitions with REORG

For partitioned table spaces, image copies that were taken before a REORG job that materialized limit key changes are not usable for recovering to a current RBA or LRSN. Avoid recovering a partitioned table space to a point-in-time that is after the REORG-pending or advisory REORG-pending status was set but before the REORG that redistributed data records. To determine an appropriate point in time:

  1. Run REPORT RECOVERY.
  2. Select an image copy for which the recovery point is a point after the REORG that redistributed data records.

Suppose that you run the REORG utility to turn off a REORG-pending status, and then recover to a point in time before that REORG job. In this case,DB2 sets restrictive statuses on all partitions that you specified in the REORG job, as follows:

  • Sets REORG-pending (and possibly CHECK-pending) on for the data partitions
  • Sets REBUILD-pending on for the associated index partitions
  • Sets REBUILD-pending on for the associated logical partitions of nonpartitioned secondary indexes
To create a new consistent recovery point, take one of the following actions immediately after an ALTER INDEX, ALTER TABLE, or REORG REBALANCE operation that changes partition boundaries:
  • Run REORG with the COPYDDN and SHRLEVEL NONE options.
  • Take a full image copy immediately after REORG completes.

Using offline copies to recover after rebalancing partitions

To recover data after a REORG job redistributes the data among partitions, use RECOVER LOGONLY. If you perform a point-in-time recovery, you must keep the offline copies synchronized with the SYSCOPY records. Therefore, do not use the MODIFY RECOVERY utility to delete any SYSCOPY records with an ICTYPE column value of 'A' because these records might be needed during the recovery. Delete these SYSCOPY records only when you are sure that you no longer need to use the offline copies that were taken before the REORG that performed the rebalancing.

Restrictions for point-in-time recoveries

The following restrictions apply to point-in-time recoveries:
  • You can take system-level backups with the BACKUP SYSTEM utility. However, if any of the following utilities were run since the system-level backup that was chosen as the recovery base, then the use of the system-level backup is prohibited for object level recoveries to a prior point in time:
    • REORG TABLESPACE
    • REORG INDEX
    • REBUILD INDEX
    • LOAD REPLACE
    • RECOVER from image copy or concurrent copy

    This restriction does not apply if you are using z/OS V1R11.0 or later and you set up DFSMShsm to capture catalog information.

  • You cannot use RECOVER to a point in time on an index to reset the REBUILD-pending state unless the index is in the REBUILD-pending state because the associated table space was recovered to a point in time, and no pending definition change is involved.
  • For an object currently involved in cloning, or one that was previously involved in cloning, a point-in-time recovery cannot be done to a time the precedes the most recent EXCHANGE statement.

Actions that can affect recovery status

When you perform the following actions before you recover a table space, the recovery status is affected as described:

  • If you alter a table to rotate a partition (with an ALTER TABLE statement and a ROTATE PARTITION clause):
    • You can recover the partition to the current time.
    • You can recover the partition to a point in time after the alter. The utility can use a recovery base, (for example, a full image copy, a REORG LOG YES operation, or a LOAD REPLACE LOG YES operation) that occurred before the alter.
    • You cannot recover the partition to a point in time before the alter; the recover fails with MSGDSNU556I and RC8.
  • If you change partition boundaries (with an ALTER TABLE statement and an ALTER PARTITION clause or with a REORG REBALANCE utility control statement):
    • You can recover the partition to the current time if a recovery base (for example, a full image copy, a REORG LOG YES operation, or a LOAD REPLACE LOG YES operation) exists.
    • You can recover the partition to a point in time after the change.
    • Start of changeYou can recover the partitions that are affected by the boundary change to a point in time before the change. However, the changed boundary is not reverted to the previous boundary. RECOVER sets REORG-pending status on the affected partitions and you must reorganize the table space or range of partitions. All affected partitions must be in the recovery list of a single RECOVER statement.End of change
  • If you alter a table to add a partition (with an ALTER TABLE statement and an ADD PARITION clause):
    • You can recover the partition to the current time.
    • You can recover the partition to a point in time after the alter.
    • You can recover the partition to a point in time before the alter; RECOVER resets the partition to be empty.
  • Start of changeIf you add a column (with an ALTER TABLE statement and an ADD COLUMN clause), you cannot recover a table space to a point in time between the time that you alter the table to add a column and the time that you take either of the following actions:
    • Drop the default value (with an ALTER TABLE statement and an ALTER COLUMN clause that specifies DROP DEFAULT)
    • Alter the default value (with an ALTER TABLE statement and an ALTER COLUMN clause that specifies SET DEFAULT)
    End of change
  • Start of changeIf you convert a table to support multiple XML versions (with a REORG TABLESPACE utility control statement):
    • You cannot recover the associated table space to a point in time before the table was converted.
    • You cannot recover any indexes for that table to a point in time before the table was converted.
    End of change
  • Start of changeIf you alter the organization of your table space to hash organization (with an ALTER TABLE statement and an ALTER ORGANIZATION clause):
    • You can recover the table space to the current time.
    • You can recover the table space to a point in time before or after the alter.
    • You can recover the table space to a point in time before or after the REORG that materialized the hash organization. RECOVER places the table space in AREOR status if the table space was recovered to a point before the REORG.
    End of change
  • Start of changeIf you alter the size of the hash space in your table space (with an ALTER TABLE statement and an ALTER ORGANIZATION clause):
    • You can recover the table space to the current time.
    • You can recover the table space to a point in time before or after the alter.
    • You can recover the table space to a point in time before or after the REORG that materialized the change in hash space size.
    End of change
  • Start of changeIf you drop the hash organization (with an ALTER TABLE statement and a DROP ORGANIZATION clause):
    • You can recover the table space to the current time.
    • You can recover the table space to a point in time after the alter.
    • You cannot recover the table space to a point in time before the alter.
    End of change
  • Start of changeIf you execute pending definition changes, you must materialize or drop those changes (with an ALTER TABLESPACE statement and a DROP PENDING CHANGES clause) before you can perform a point-in-time recovery.
    Examples: Changing the following characteristics results in pending definition changes: Start of change
    • The segment size (with an ALTER TABLESPACE statement and a SEGSIZE clause)
    • The data set size (with an ALTER TABLESPACE statement and a SEGSIZE clause)
    • The buffer pool page size (with an ALTER TABLESPACE statement and a BUFFERPOOL clause)
    • The MEMBER CLUSTER attribute (with an ALTER TABLESPACE statement and a MEMBER CLUSTER clause)
    • The table space type (with an ALTER TABLESPACE statement)
    End of change
    End of change
  • Start of changeIf you perform any of the following SQL operations on a table in a segmented table space or universal table space, you cannot back out the changes (with a RECOVER utility control statement and a BACKOUT YES clause):
    • DELETE without a WHERE clause (mass DELETE)
    • TRUNCATE TABLE
    • DROP TABLE
    • ALTER TABLE with a ROTATE PARTITION clause

    If you perform any of the previously indicated actions on tables in a base table space that has indexes or auxiliary objects (LOB tables spaces or XML table spaces), this restriction also applies to those indexes or auxiliary objects.

    End of change
When you perform the following actions before you recover an index to a prior point in time or to the current time, the recovery status is affected as described:
  • If you alter the data type of a column to a numeric data type (with an ALTER TABLE statement and an ALTER COLUMN clause specifying the new data type), you cannot recover the index until you take a full image copy of the index. However, the index can be rebuilt.
  • If you alter an index to NOT PADDED or PADDED (with an ALTER INDEX statement and a NOT PADDED or PADDED clause), you cannot recover the index until you take a full image copy of the index. However, the index can be rebuilt.
  • If you regenerate an index (with an ALTER INDEX statement and a REGENERATE clause), you cannot recover the index or index space to a point in time prior to the time that it was regenerated. Instead, rebuild the index by using the REBUILD INDEX utility.
  • If you alter an index such that DB2 creates a new version of the index, you cannot recover the index to a point in time prior to the first ALTER INDEX statement that created a new version of that index.

Planning for point-in-time recovery

Recovering to a point in time that is a point of consistency (QUIESCE or SHRLEVEL REFERENCE set) is desirable because there will be no uncommitted work to back out.

When making copies of a single object, use SHRLEVEL REFERENCE to establish consistent points for TOCOPY, TOLASTCOPY, or TOLASTFULLCOPY recovery. Copies that are made with SHRLEVEL CHANGE do not copy data at a single instant because changes can occur as the copy is made. A subsequent RECOVER TOCOPY operation can produce inconsistent data. Instead use RECOVER with the TOLOGPOINT option to identify a point after the SHRLEVEL CHANGE copy and any uncommitted units of work will be backed out.

When copying a list of objects, use SHRLEVEL REFERENCE. If a subsequent recovery to a point in time is necessary, you can use a single RECOVER utility statement to list all of the objects, along with TOLOGPOINT to identify the common RBA or LRSN value. If you use SHRLEVEL CHANGE to copy a list of objects, you should follow it with a QUIESCE of the objects.

To improve the performance of the recovery, take a full image copy of the table space or set of table spaces, and then quiesce them by using the QUIESCE utility. This action enables RECOVER TORBA or TOLOGPOINT to recover the table spaces to the quiesce point with minimal use of the log.

Authorization: Restrict use of the point-in-time recovery options to personnel with a thorough knowledge of the DB2 recovery environment.

Ensuring consistency

You can use RECOVER TORBA, RECOVER TOLOGPOINT, and RECOVER TOCOPY to recover one of the following single objects:

  • Partition of a partitioned table space
  • Partition of a partitioning index space
  • Data set of a simple table space

For any of the previously listed objects, restore all data sets to the same level; otherwise, the data becomes inconsistent.

If possible, specify a table space and all of its indexes (or a set of table spaces and all related indexes) in the same RECOVER utility statement, and specify TOLOGPOINT or TORBA to identify a QUIESCE point. This action avoids placing indexes in the CHECK-pending or REBUILD-pending status. If the TOLOGPOINT is not a common QUIESCE point for all objects, use the following procedure:

  1. RECOVER table spaces to the value for TOLOGPOINT (either an RBA or LRSN).
  2. Use concurrent REBUILD INDEX jobs to recover the indexes over each table space.

This procedure ensures that the table spaces and indexes are synchronized, and it eliminates the need to run the CHECK INDEX utility.

If you cannot specify TOLOGPOINT or TORBA to identify a QUIESCE point, you can specify any point in time, and DB2 will leave the data in a consistent state. The RECOVER utility automatically handles any uncommitted units of work and leaves the data in a consistent state when TORBA or TOLOGPOINT is specified.

When using RECOVER with the TORBA or TOLOGPOINT option, ensure that all of the objects that are changed by the active units of recovery at the recovery point are recovered to the same point-in-time so that they are synchronized:

  • DB2 rolls back changes made to units of recovery that are inflight, inabort, postponed abort, or indoubt during the recovery point-in-time.
  • DB2 does not roll back changes made to units of recovery that are INCOMMIT during the recovery point-in-time.
  • DB2 rolls back only changes to objects in the RECOVER statement.

Avoiding CHECK-pending status

DB2 sets CHECK-pending status in the following point-in-time-recovery situations:

  • You recover at least one member of a table space set to a prior point in time, but you do not recover all members of the table space set to the same quiesce point. In this case, all dependent table spaces that are recovered are placed in CHECK-pending status with the scope of the whole table space. All dependent table spaces of the recovered table spaces are placed in CHECK-pending status with the scope of the specific dependent tables.
  • The RECOVER statement contains the TORBA option or TOLOGPOINT option and recovers all members of a table space set to the same point in time. However, referential constraints were defined in one of those table spaces after that point in time. In this case, the CHECK-pending status is set for the table space that contains the table with the referential constraint.
  • The RECOVER statement contains the TORBA option or TOLOGPOINT option and recovers one or more indexes to a previous point in time. However, the same RECOVER statement does not recover the related table space. In this case, DB2 sets the CHECK-pending status for the indexes.
  • Start of changeIn DB2 10 conversion mode, the RECOVER statement contains the TORBA option or TOLOGPOINT option and recovers table spaces with defined LOB or XML columns without recovering their LOB or XML table spaces. In DB2 10 new-function mode, base table spaces and their associated LOB or XML table spaces must be recovered together.End of change

RECOVER does not place dependent table spaces that are related by informational referential constraints into CHECK-pending status.

To avoid setting CHECK-pending status, take the following actions:

  • When you recover tables that are involved in a referential constraint, recover all of the table spaces that are involved in the constraint.
  • Recover all dependent objects to the same point in time.
  • Do not add table check constraints or referential constraints after the point in time to which you want to recover.
  • Recover indexes and the related table space to the same point in time (preferably a quiesce point) or COPY SHRLEVEL REFERENCE point. RECOVER processing resets the CHECK-pending status for all indexes in the same RECOVER statement.

Compressed data

Use caution when recovering a portion of a table space or partition (for example, one data set) to a prior point in time. If the data set that is being recovered has been compressed with a different dictionary, you can no longer read the data.