Module 14: DB2 Locking, Recovery and Performance
Image Copies
An image copy is a backup of a tablespace or index taken by the DB2 COPY utility. It is the starting point for every media recovery, so a tablespace without a recent image copy is a tablespace you cannot recover quickly.
What is an image copy
- An image copy is a dataset holding a page-by-page copy of a tablespace or index at one moment in time.
- Full image copy: copies every page. Needed as the base for recovery.
- Incremental image copy: copies only pages changed since the last full copy. Faster, but recovery must merge it with the full copy.
- COPYTOCOPY makes a second copy of an existing image copy, usually kept on different storage for safety.
- Every copy is recorded in the SYSIBM.SYSCOPY catalog table, which RECOVER reads to find the right datasets.
Taking an image copy
- Run the COPY utility in a JCL job naming the tablespace. FULL YES takes a full copy.
- SHRLEVEL REFERENCE lets readers in but blocks writers during the copy. SHRLEVEL CHANGE lets writers continue, but the copy may need log apply at recovery.
- Copy indexes too when the tablespace is critical, so recovery does not have to rebuild them.
- Example JCL:-//COPY EXEC DSNUPROC,SYSTEM=DB2T //SYSIN DD * COPY TABLESPACE DBONE.TSONE FULL YES SHRLEVEL REFERENCE /*
Image copies and recovery
- RECOVER restores the newest full image copy, applies any incremental copy, then rolls the DB2 logs forward.
- The fresher the image copy, the less log DB2 must apply and the faster the recovery.
- Schedule copies around the recovery target: daily copies for critical tables, weekly for quiet ones.
- After LOAD REPLACE or REORG, the old copies are useless. Take a new full copy immediately (or use LOG YES options).
