The DB2 RECOVER utility

RECOVER restores DB2 for z/OS data from image copies and then applies the log. You can go to current, to a specific copy, or to a log point (RBA or LRSN). This page covers TABLESPACE, INDEX, DATABASE, partitions, recover-to options, SHRLEVEL, dependencies, and the SYSCOPY history that makes it possible.

Db2 utilities
Progress0 of 0 lessons

RECOVER TABLESPACE, INDEX, and DATABASE

The largest everyday unit is a table space or index; the smallest is a page. Name objects explicitly:

text
1
2
3
4
RECOVER TABLESPACE HRDB.HRTS RECOVER INDEX HR.XEMP1 RECOVER TABLESPACE HRDB.HRTS DSNUM 3 RECOVER DATABASE HRDB
  • TABLESPACE — restore that space (all partitions unless DSNUM)
  • INDEX / INDEXSPACE — requires COPY YES indexes with image copies; otherwise REBUILD INDEX from the table
  • DSNUM / PART — one partition or piece
  • DATABASE — all recoverable table spaces in the database; easy to recover more than you intended
  • LIST — LISTDEF of a table space set plus indexes in one statement (best for PIT)

This RECOVER utility is not -RECOVER BSDS or -RECOVER INDOUBT. Those are operator commands on a different page.

Recover to current

With no TOCOPY/TORBA/TOLOGPOINT, RECOVER restores the latest usable full copy, merges incrementals, then applies log until the object is current. That is the path after media failure: DASD gone, copies and logs intact. Phases you will see in SYSPRINT:

Important RECOVER phases (IBM Utility Guide)
PhaseRole
UTILINITSetup
RESTORELocate/merge sequential copies and restore pages
LOGAPPLY / related log phasesApply log from copy RBA/LRSN toward the target
LOGCSR / LOGUNDOFor PIT: complete/abort URs so the PIT is consistent

Point-in-time recovery

How you name the stopping point
OptionMeaning
(none)Recover to current: restore copies, apply all later log
TOCOPY dsnameStop at that image copy (use SHRLEVEL REFERENCE copies)
TOLASTCOPY / TOLASTFULLCOPYLast (full) copy registered in SYSCOPY
TORBA X'rba'Point-in-time at that RBA
TOLOGPOINT X'lrsn'Point-in-time at that LRSN (data sharing clock)
text
1
2
3
4
5
6
7
8
9
10
RECOVER TABLESPACE HRDB.HRTS INDEX HR.XEMP1 TOLOGPOINT X'00000000000000000000' * use the real LRSN from QUIESCE / SYSCOPY RECOVER TABLESPACE HRDB.HRTS TORBA X'000000000000' RECOVER TABLESPACE HRDB.HRTS TOCOPY HR.COPY.HRTS.G0005V00

After PIT, RECOVER may set COPY-pending, CHECK-pending, or REBUILD-pending on related objects you did not include. Always recover a table space set (parents and children) and indexes together to the same QUIESCE point.

Recover to RBA and LRSN

An RBA (relative byte address) locates a position in a non-data-sharing log. An LRSN (log record sequence number) is the data-sharing clock.TOLOGPOINT is the keyword you should default to in a data sharing group; TORBA remains common on standalone subsystems. Both take a hex string.

Recover to a timestamp

There is no RECOVER TO TIMESTAMP keyword. Operational practice:

  • Take QUIESCE at application-consistent times (end of batch) so SYSCOPY records a timestamped log point (ICTYPE Q)
  • Or SELECT TIMESTAMP, START_RBA / PIT_RBA, DSNAME FROM SYSIBM.SYSCOPY WHERE …
  • Then TORBA or TOLOGPOINT that value

Wall-clock “Tuesday 14:07” is meaningless to RECOVER until you translate it into a log point.

RECOVERYDDN and where copies come from

RECOVERYDDN is specified on COPY (and MERGECOPY / COPYTOCOPY), not as the main recover syntax. It creates the remote-site sequential copies. At the DR site, RECOVER reads SYSIBM.SYSCOPY (restored with the catalog) and allocates those data sets. Local recover uses COPYDDN copies. LOGONLY skips RESTORE when the VSAM data sets are already restored from a system-level backup or FlashCopy and you only need log apply.

RECOVER SHRLEVEL

Classic recover needs the object not in use (often STOP or UTUT). Later Db2 releases added SHRLEVEL CHANGE recover paths that restore to a shadow and switch, similar in spirit to online REORG. Restrictions apply (object types, PIT versus current). Until your shop standardizes on online recover, treat recover as an outage window: STOP the space, RECOVER, START, RUNSTATS if needed.

Recovery dependencies

  • Image copies — full plus incrementals; GDG generations still on DASD or tape
  • Logs — active and archive covering copy RBA through target; BSDS must know the archive inventory
  • SYSLGRNX (directory) — log ranges per object so RECOVER does not scan the entire log
  • Catalog SYSCOPY — without it, RECOVER does not know DSNAME
  • Referential sets — recover parents and children to the same PIT
  • Indexes — same PIT or accept RBDP and REBUILD

MODIFY RECOVERY deletes old SYSCOPY rows and SYSLGRNX ranges. Run it on a schedule, but never delete the last full copy you still need. REPORT RECOVERY is the rehearsal.

Recovery history (SYSCOPY)

sql
1
2
3
4
5
6
7
SELECT TIMESTAMP, ICTYPE, ICBACKUP, DSNUM, DSNAME, HEX(START_RBA) AS START_RBA, SHRLEVEL FROM SYSIBM.SYSCOPY WHERE DBNAME = 'HRDB' AND TSNAME = 'HRTS' ORDER BY TIMESTAMP DESC WITH UR;

ICTYPE values you will learn: F full, I incremental, Q quiesce, S Load/Reorg inline, and others in the SQL Reference. ICBACKUP distinguishes local versus recovery-site copies. Keep this query in the runbook next to the RECOVER job.

text
1
2
3
4
5
6
//RECOVER EXEC DSNUPROC,SYSTEM=DB2T,UID='HR.RECV.HRTS' //SYSPRINT DD SYSOUT=* //SYSIN DD * RECOVER TABLESPACE HRDB.HRTS INDEX HR.XEMP1 /*

Explain It Like I'm Five

Imagine a LEGO castle. COPY took photographs (image copies). The diary (the log) wrote down every brick that moved afterward. RECOVER builds last night’s photograph, then reads the diary until “now” (recover to current) or until a bookmark in the diary (RBA / LRSN) or until a particular photograph (TOCOPY). A QUIESCE bookmark means everyone put their hands in their laps so the castle and the little flag (the index) match. A timestamp is just the clock on the wall—you still have to find the matching diary page. RECOVERYDDN is the photo album stored at grandma’s house for when your house floods.

Exercises

  1. Write RECOVER to current for a table space and its clustering index.
  2. Using a SYSCOPY QUIESCE row, write TOLOGPOINT recovery for a parent and child table space.
  3. Explain why TOCOPY of a SHRLEVEL CHANGE copy is riskier than TOLOGPOINT PIT_RBA.
  4. Run (or draft) REPORT RECOVERY for a table space and list the copy data sets it would allocate.
  5. Contrast this utility with -RECOVER INDOUBT in one paragraph.

Quiz

Test Your Knowledge

1. What does RECOVER do by default (no TORBA/TOCOPY)?

  • Drops the table space
  • Restores the latest applicable image copies and applies log until current
  • Only runs RUNSTATS
  • Copies the BSDS

2. TORBA versus TOLOGPOINT:

  • They are unrelated to recovery
  • Both name a log point; TORBA uses an RBA, TOLOGPOINT uses an LRSN (required thinking in data sharing) written as X'hex'
  • TORBA only recovers indexes
  • TOLOGPOINT deletes SYSCOPY

3. Why is a QUIESCE a good PIT?

  • It drops indexes
  • It is a common point of consistency across a table space set so RI and indexes stay aligned
  • It replaces COPY
  • It turns off logging forever

4. RECOVERYDDN is primarily an option of:

  • SELECT
  • COPY (and related copy utilities)—it creates the remote image copies RECOVER at a DR site will restore
  • DSN1PRNT
  • BIND

5. TOCOPY of a SHRLEVEL CHANGE copy can:

  • Never be used
  • Yield inconsistent pages; IBM prefers TORBA/TOLOGPOINT using SYSCOPY.PIT_RBA after that copy
  • Always match a QUIESCE
  • Skip the log always