COPY is how DB2 for z/OS takes image copies of table spaces and copyable indexes. RECOVER later restores those data sets and applies the log. This page covers COPY TABLESPACE, COPY INDEX, COPYDDN / RECOVERYDDN, full versus incremental copies, and SHRLEVEL.
Name the database and table space. Optional DSNUM copies one partition or data set. LIST copies a LISTDEF of objects in one utility statement.
1234COPY TABLESPACE HRDB.HRTS COPYDDN(SYSCOPY) FULL YES SHRLEVEL REFERENCE
JCL needs SYSIN, SYSPRINT, and the COPYDDN data set (traditional name SYSCOPY). Many shops use TEMPLATE with GDG (+1) so each copy is a new generation. The utility inserts a row in SYSIBM.SYSCOPY with DSNAME, ICTYPE, SHRLEVEL, START_RBA / PIT_RBA, TIMESTAMP, and DSNUM.
Indexes are created COPY NO by default. ALTER INDEX … COPY YES (or CREATE INDEX COPY YES) makes the index space eligible for COPY and RECOVER instead of only REBUILD INDEX. Incremental copies of indexes are not supported: if a LIST mixes a table space FULL NO with an index, COPY takes a full copy of the index and does not fail the list. A statement that names only an index with FULL NO fails.
1234COPY INDEX HR.XEMP1 COPYDDN(IXCOPY) FULL YES SHRLEVEL REFERENCE
Both options take one or two names: primary and optional backup.
You do not have to take local and remote copies in the same job. If remote copies are less frequent, DR recovery uses an older full copy plus more log. IBM documents that incremental COPY for a site can fail RC 8 if the full/incremental history is not aligned between local and recovery sites—take a fresh full for both, or incremental only for the site you are on.
123456TEMPLATE LOC DSN HR.COPY.&DB..&TS..L.&DATE. TEMPLATE REM DSN HR.COPY.&DB..&TS..R.&DATE. COPY TABLESPACE HRDB.HRTS COPYDDN(LOC) RECOVERYDDN(REM) FULL YES SHRLEVEL REFERENCE
| Option | Meaning |
|---|---|
| FULL YES | All allocated pages; resets COPY-pending; valid for table spaces and COPY YES indexes |
| FULL NO | Incremental: pages changed since last copy; not valid for indexes; needs TRACKMOD for speed |
A full copy is a complete backup of the pages in the object (or partition). It is the base of every recovery chain. After LOAD LOG NO, REORG LOG NO, or other COPY-pending events, you need a full copy (or an inline COPYDDN on the utility) before the object is backup-clean. FlashCopy image copies are data-set-level full copies; they are not incremental.
FULL NO copies pages that changed since the last full or incremental copy. Space maps (when TRACKMOD YES) let COPY skip unchanged pages, which is why incrementals are faster on large, lightly updated spaces. TRACKMOD NO still produces a smaller sequential file but may scan more like a full copy.
IBM prerequisites:
123COPY TABLESPACE DSN8D12A.DSN8S12E FULL NO SHRLEVEL CHANGE
MERGECOPY later merges incrementals into a new full copy so RECOVER does not need a long incremental chain. Some catalog/directory objects always force a full copy.
| Option | Meaning |
|---|---|
| SHRLEVEL REFERENCE | Read-only during COPY; default in IBM teaching for consistent copies |
| SHRLEVEL CHANGE | Read and write allowed; copy is fuzzy; plan PIT_RBA for recover |
REFERENCE drains writers so SELECT can run but UPDATE cannot. It is the copy you want if you plan to RECOVER TOCOPY / TOLASTCOPY. CHANGE claims the read class so inserts and updates continue; do not treat the data set as a crash-consistent instant. CONCURRENT (DFSMSdss concurrent copy) has extra page-size versus CI-size rules: SHRLEVEL CHANGE is not allowed for some large page sizes when the CI does not match.
A DELETE without WHERE on a segmented space is a documented exception that can conflict with COPY SHRLEVEL CHANGE—know that restriction before you schedule overnight copies during batch.
12345678910//COPYTS EXEC DSNUPROC,SYSTEM=DB2T,UID='HR.COPY.HRTS' //SYSCOPY DD DSN=HR.COPY.HRTS(+1),DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(50,10),RLSE) //SYSPRINT DD SYSOUT=* //SYSIN DD * COPY TABLESPACE HRDB.HRTS COPYDDN(SYSCOPY) FULL YES SHRLEVEL REFERENCE /*
REPORT RECOVERY and a SELECT from SYSIBM.SYSCOPY are how you verify the copy landed before you need it. The RECOVER utility page shows how those SYSCOPY rows are consumed.
COPY is taking a photograph of the classroom. A full photo shows every desk. An incremental photo shows only desks that changed since the last picture. COPYDDN is the album you keep at school; RECOVERYDDN is the album you mail to the backup school. SHRLEVEL REFERENCE means “nobody move while I take the picture.” SHRLEVEL CHANGE means “keep playing; the photo might show a kid in two places.” RECOVER later uses the album plus the diary (the log) to rebuild the room.
1. FULL YES versus FULL NO on COPY means:
2. COPYDDN names:
3. SHRLEVEL REFERENCE allows:
4. A prerequisite for incremental COPY is:
5. COPY INDEX requires: