DB2 COPY-related utilities and options

COPY is not the only utility that writes recovery backups. MERGECOPY shortens incremental copy chains. LOAD and REORG write inline copies so you do not leave COPY-pending after LOG NO. COPYTOCOPY duplicates an existing copy for the local backup or recovery site without touching the table space. This page explains those DB2 for z/OS copy-family utilities and how they share SYSIBM.SYSCOPY.

Db2 utilities
Progress0 of 0 lessons

The copy family

Think of four jobs that all talk to SYSCOPY:

  • COPY — reads the table space or index space and writes sequential or FlashCopy backups
  • Inline COPYDDN — LOAD, REORG, and REBUILD write a full copy while they already have the pages in hand
  • COPYTOCOPY — reads an existing primary or FlashCopy backup and writes more sequential copies
  • MERGECOPY — reads existing sequential copies and writes a merged incremental or a new full copy

RECOVER, UNLOAD FROMCOPY, and DSN1COPY consume the data sets those jobs catalog. If you mix FlashCopy, concurrent copy, local COPYDDN, and recovery-site RECOVERYDDN, the rules below keep the chain legal.

Merge copy chains

Every incremental COPY adds another data set RECOVER must allocate when it restores to current or to a point after that incremental. Ten incrementals on tape can mean ten drives (or a painful wait). MERGECOPY collapses that chain without reading the table space, so applications keep running. The only notable lock is access to SYSIBM.SYSCOPY.

MERGECOPY NEWCOPY
OptionOutput copySYSCOPY effect
NEWCOPY YESNew full image copyInserts a new full-copy row; incrementals remain until MODIFY RECOVERY
NEWCOPY NOSingle merged incrementalReplaces the SYSCOPY rows of the incrementals that were merged

IBM recommends NEWCOPY YES in general: you get a new recovery point, tape count during RECOVER drops to one full copy, and the log range RECOVER applies is the same as if you had kept the incrementals. NEWCOPY NO is useful when you only want to stack incrementals into one smaller incremental without rereading the full copy.

Site rules for NEWCOPY NO

  • At recovery sites, you cannot use COPYDDN with NEWCOPY NO
  • At local sites, you cannot use RECOVERYDDN with NEWCOPY NO
  • If you omit NEWCOPY, COPYDDN, and RECOVERYDDN, the default is NEWCOPY NO COPYDDN(SYSCOPY) at the local site

What MERGECOPY will not merge

You cannot run MERGECOPY on concurrent copies or FlashCopy image copies. If image copies were taken by data set (DSNUM) rather than by table space, MERGECOPY must merge by data set. Do not specify DSNUM and LIST on the same statement; use PARTLEVEL on LISTDEF instead.

WORKDDN and partial merges

WORKDDN (default SYSUT1) names a temporary data set for intermediate merged output when you cannot allocate every input copy at once. If you omit WORKDDN and run out of units, MERGECOPY may merge only some data sets and issue a message with the counts. Repeat MERGECOPY with a new output data set to continue. Keep tape mounts (RETPD, volume counts) in mind when inputs are on cartridge.

text
1
2
3
4
5
6
7
8
9
10
//STEP1 EXEC DSNUPROC,SYSTEM=DB2T,UID='HR.MRG.HRTS' //SYSCOPY DD DSN=HR.COPY.HRTS.MERGED(+1),DISP=(NEW,CATLG,DELETE), // UNIT=TAPE,LABEL=(1,SL) //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(50,20),RLSE) //SYSIN DD * MERGECOPY TABLESPACE HRDB.HRTS NEWCOPY YES COPYDDN(SYSCOPY) WORKDDN(SYSUT1) /*

After NEWCOPY YES, run REPORT RECOVERY and confirm the new full DSNAME appears. Schedule MODIFY RECOVERY later to delete obsolete incremental rows and data sets according to your retention standard—MERGECOPY YES does not by itself delete the old incrementals.

Avoid MERGECOPY LOG RBA inconsistencies by not mixing copy methods that IBM documents as incompatible (for example following a CONCURRENT copy with incrementals, or expecting FlashCopy inputs). If local and recovery-site histories drifted apart, take a fresh full COPY for both sites before you merge.

Inline copy processing

Inline copy processing means: while LOAD, REORG, or REBUILD already scans or reloads pages, write those pages to COPYDDN (local) and optionally RECOVERYDDN (recovery site). You skip a separate COPY utility, avoid COPY-pending after LOG NO, and record a full SHRLEVEL REFERENCE copy in SYSCOPY.

Who writes inline copies
UtilityWhen the copy is writtenNote
LOAD REPLACE COPYDDNRELOAD phaseAvoids COPY-pending after LOG NO; STYPE R or S
REORG TABLESPACE COPYDDNDuring REORG (required with SHRLEVEL REFERENCE/CHANGE or LOG NO recovery design)Partition-range inline copies need DSNUM on later COPYTOCOPY
REORG INDEX / REBUILD INDEX COPYDDNIndex rebuild/reloadFull index copy; incrementals still not valid for indexes

LOAD inline copies

Specify COPYDDN and RECOVERYDDN on LOAD. Inline copies are produced in the RELOAD phase. You can specify up to two primary and two secondary copies. LOAD REPLACE is required for some inline-copy cases (IBM: to create an inline copy you must also specify REPLACE when replacing the table space contents). SYSCOPY ICTYPE=F, SHRLEVEL=R. STYPE is R for LOAD REPLACE LOG YES and S for LOAD REPLACE LOG NO.

The sequential file is logically a full REFERENCE copy, but pages may be out of physical order. RECOVER handles that. Do not assume a dump of the data set looks like a stand-alone COPY.

text
1
2
3
4
TEMPLATE LOC DSN HR.COPY.&DB..&TS..L.&DATE. LOAD DATA INDDN(SYSREC) REPLACE LOG NO COPYDDN(LOC) INTO TABLE HR.EMPLOYEE

REORG inline copies

REORG TABLESPACE with COPYDDN (or SHRLEVEL REFERENCE/CHANGE, which takes an image copy during execution) writes an inline copy of the reorganized data. That copy is the natural recovery base after a successful SWITCH. If you REORG a range of partitions into one inline data set, COPYTOCOPY does not support part-range: you must specify individual DSNUM values so COPYTOCOPY copies only that partition’s pages from the inline file.

An inline copy cannot be created for a LOB table space while running a REORG of that LOB space in the situations IBM documents as restricted—copy LOB spaces with COPY, or follow the Utility Guide for your release.

After the inline copy

COPYTOCOPY can start from the local primary, recovery-site primary, or a FlashCopy and make up to three (or four, if the base is FlashCopy) additional sequential copies: local primary, local backup, recovery primary, recovery backup. MERGECOPY can then merge sequential incrementals that follow that full inline copy. CONCURRENT copies are not valid input to COPYTOCOPY.

text
1
2
3
4
COPYTOCOPY TABLESPACE HRDB.HRTS FROMLASTCOPY COPYDDN(LOCBKUP) RECOVERYDDN(REM)

Catalog and directory restrictions apply: COPYTOCOPY does not support certain objects (including DSNDB06.SYSTSCPY, DSNDB01.DBD01, SYSUTILX, SYSDBDXA and their indexes). Plan those copies with COPY itself under the documented catalog-copy procedures.

Choosing COPY versus MERGECOPY versus COPYTOCOPY

Use COPY when you need a new backup of the live pages. Use inline COPYDDN when LOAD or REORG is already running and you would otherwise be COPY-pending. Use COPYTOCOPY when the backup already exists and you need another sequential file (tape vault, DR site, UNLOAD input from a FlashCopy). Use MERGECOPY when the chain of incrementals is getting long and you want RECOVER to allocate fewer data sets.

COPY versus MERGECOPY for “I want a new full”: COPY rereads the table space (and may drain writers). MERGECOPY NEWCOPY YES rereads only the existing copy data sets. If the table is huge and incrementals are small, MERGECOPY is often cheaper. If incrementals were never taken, COPY FULL YES is the only option.

Explain It Like I'm Five

Imagine a photo album. COPY takes a new photo of the classroom. LOAD and REORG take a photo while they rearrange the desks (inline copy) so you do not forget to photograph afterwards. COPYTOCOPY is the photocopier: it copies a photo you already have so Grandma (the DR site) gets a copy without making the kids sit still again. MERGECOPY is gluing many “only the desks that changed” snapshots onto one page so the substitute teacher (RECOVER) does not have to carry ten envelopes of photos.

Exercises

  1. Write MERGECOPY NEWCOPY YES for a table space with COPYDDN and WORKDDN. Explain what SYSCOPY looks like afterwards.
  2. State the NEWCOPY NO COPYDDN/RECOVERYDDN site restrictions in one sentence each.
  3. Add COPYDDN to a LOAD REPLACE LOG NO job and predict ICTYPE, SHRLEVEL, and STYPE.
  4. Explain why COPYTOCOPY after a partition-range REORG inline copy needs DSNUM.
  5. List two copy types MERGECOPY will refuse, and the utility you would run instead to get a sequential file.

Quiz

Test Your Knowledge

1. What does MERGECOPY NEWCOPY YES do?

  • Deletes SYSIBM.SYSCOPY
  • Merges the full image copy with later incrementals and inserts a new full-copy SYSCOPY row (a new recovery point)
  • Only copies the BSDS
  • Runs only on indexes

2. MERGECOPY NEWCOPY NO:

  • Creates a FlashCopy
  • Merges several incrementals into one incremental and replaces those incremental SYSCOPY rows; it does not merge with the full copy
  • Always requires RECOVERYDDN at the local site
  • Resets COPY-pending

3. Which copies can MERGECOPY not merge?

  • Ordinary sequential incrementals
  • Concurrent copies and FlashCopy image copies
  • Inline copies from LOAD
  • Local primary copies

4. An inline copy from LOAD REPLACE LOG NO is recorded in SYSCOPY as:

  • ICTYPE Q
  • A full copy (ICTYPE F) with SHRLEVEL R; STYPE S for LOG NO REPLACE
  • Always incremental
  • A system-level backup

5. Why run COPYTOCOPY after a FlashCopy or inline copy?

  • To start Db2
  • To make additional sequential local/recovery-site copies that UNLOAD, MERGECOPY, and RECOVER can use without taking another application outage
  • To drop the table space
  • To format the active log

Frequently Asked Questions