DB2

Following sections will show how to configure your DB2 system to use cxLink Backup functionalities.

All commands in this guide are executed using an SAP Database with SID DBD. Please replace DBD with your actual database SID.

Only DB2 SAP instances are supported by cxLink Backup. It is not possible to use cxLink Backup for a DB2 standalone database.

WARNING

If you are using a release prior to 2301.27 Maki, CxLink Backup library name to be used is libemory.so instead of libemorydb2.so

Topics


Configure database archive log

To be able to recover a DB2 database with Point in Time options, database archive logging must be activated and configured to use cxLink Backup solution library.

Check actual archiving configuration using command:

db2 get db configuration for DBD

Archiving related parameters from command output:

First log archive method                 (LOGARCHMETH1) = VENDOR:/opt/emory/lib/libemorydb2.so
Archive compression for logarchmeth1    (LOGARCHCOMPR1) = OFF
Options for logarchmeth1                  (LOGARCHOPT1) =
Second log archive method                (LOGARCHMETH2) = OFF
Archive compression for logarchmeth2    (LOGARCHCOMPR2) = OFF
Options for logarchmeth2                  (LOGARCHOPT2) =
Failover log archive path                (FAILARCHPATH) =
Number of log archive retries on error   (NUMARCHRETRY) = 5
Log archive retry Delay (secs)         (ARCHRETRYDELAY) = 20
Vendor options                              (VENDOROPT) =

First log archive method must be “VENDOR:/opt/emory/lib/libemorydb2.so” with no parameters, no compression, and no vendor options by using “db2 update” command:

db2 update db configuration for DBD using logarchmeth1 “VENDOR:/opt/emory/lib/libemorydb2.so”
db2 update db configuration for DBD using logarchcompr1 “OFF”
db2 update db configuration for DBD using logarchopt1 “”
db2 update db configuration for DBD using vendoropt “”

Backup, restore and archive log history

Every single time DB2 finishes a backup, log archive or restore action, backup history is updated.

You can display actual DB2 database backup history by executing “db2 list history” like:

Backup history:


db2 list history backup all for DBD

Archive log history:

db2 list history archive log all for DBD

List history command has many options. Please read DB2 database documentation from IBM for more information.

These are different sections from command output:

Offline backup:


--------------------------------------------------------------------------
   Comment: DB2 BACKUP DBD OFFLINE
Start Time: 20211224073135
  End Time: 20211224073234
    Status: I
--------------------------------------------------------------------------
 EID: 2618 Location: /opt/emory/lib/libemorydb2.so

Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
-- --- ------------------ ---- --- ------------ ------------ ------------
 B  D  20211224073135002   F    O  S0000002.LOG S0000002.LOG
--------------------------------------------------------------------------
 Contains 68 Tablespace(s):

00001 SYSCATSPACE

Archive log:


--------------------------------------------------------------------------
   Comment:
Start Time: 20220104063242
  End Time: 20220104063249
    Status: A
--------------------------------------------------------------------------
 EID: 4013 Location: /opt/emory/lib/libemorydb2.so

 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ ------------
  X  D  20220104063314      P    D  S0000249.LOG C0000015
--------------------------------------------------------------------------

Restore:


-----------------------------------------------------------------------------
   Comment: RESTORE DBD WITH RF
Start Time: 20211230101407
  End Time: 20211230101838
    Status: A
-----------------------------------------------------------------------------
 EID: 3432 Location:

 Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log  Backup ID
 -- --- ------------------ ---- --- ------------ ------------ --------------
  R  D  20211230103250001   F                                 20211230065525
-----------------------------------------------------------------------------
 Contains 68 Tablespace(s):

00001 SYSCATSPACE

You can execute a backup operation using cxLink Backup Library from either command line or SAP database management transaction DB13.

Command Line Full Offline Backup

To execute a full offline backup, SAP application must be stopped and DB2 database deactivated.

Follow the steps as database administrator except first step that must be executed as SAP instance administrator:

  • Stop SAP instance
stopsap r3 
  • Disconnect all connections
db2 force application all
  • Terminate DB2 database
db2 terminate
  • Deactivate DB2 database
db2 deactivate db DBD
  • Stop DB2 database
db2stop force
  • Restart the database in restricted access mode
db2start admin mode restricted access
  • Execute backup with the desired options (compression, encryption, opening parallel I/O sessions, ...) In the example a backup using compression and 4 parallel I/O sessions is executed:
db2 backup db DBD load /opt/emory/lib/libemorydb2.so open 4 sessions compress

Command Line Full Online Backup

To execute an online backup, SAP application and DB2 database are up and running.

Follow the steps as database administrator:

  • Execute backup with the desired options.

    In that case a backup with compression and 4 I/O parallel sessions is executed:

    db2 backup db DBD online load /opt/emory/lib/libemorydb2.so open 4 sessions compress
    

Command Line Incremental Online Backup

To execute an incremental online backup, SAP application and DB2 database are started. Follow the steps as database administrator:

  • Execute backup with the desired options.

In that case a backup with compression and 4 I/O parallel sessions is called:

db2 backup db DBD online incremental load /opt/emory/lib/libemorydb2.so open 4 sessions compress

Command Line Delta Online Backup

To execute a delta online backup, SAP application and DB2 database are started. Follow the steps as database administrator:

  • Execute backup with the desired options.

In that case a backup with compression and 4 I/O parallel sessions is called:

db2 backup db DBD online incremental delta load /opt/emory/lib/libemorydb2.so open 4 sessions compress

SAP GUI Full Online Backup

Follow the steps with a properly authorized SAP user:

  • Access DB13 transaction

DB13

  • Schedule a new action using Add button and select Database Backup with Vendor Library:

Database Backup with vendor Library

  • Configure your backup with the desired options. In that case it is a full online backup including logs, compressing with default DB2 compression library, and opening 4 I/O sessions:

Full Online Backup

Specify cxLink Backup library:

Specify cxLink Backup library

  • Check backup result in the calendar:

Check calendar

You can read result and cxLink Backup application log:

Check Backup logCheck Backup log detail

SAP GUI Incremental Online Backup

You can use DB13 transaction to schedule and execute an incremental online backup.

All execution steps won’t be reproduced here as they are the same described for SAP GUI Full Online Backup, just Incremental option must be selected:

Incremental Online Backup

SAP GUI Delta Online Backup

You can use DB13 transaction to schedule and execute a delta online backup.

All execution steps won’t be reproduced here as they are the same described for SAP GUI Full Online Backup, just Incremental Delta option must be selected:

Incremental Delta Online Backup

You can execute a restore operation using cxLink Backup Library from command line.

During all restore operations SAP application and DB2 database must be stopped.

A restore operation from command line can be executed using either db2 recover command with different options or db2 restore plus db2 rollforward if needed.

Command Line Database Recover

You can execute just a recover operation with no additional parameters and last successful full backup and incremental/delta/archives if needed will be restored to the last consistent database state.

Follow the steps:

  • Stop SAP application and deactivate DB2 Database
  • Execute command:
db2 recover db DBD

You can also specify a point in time and DB2 will retrieve necessary files from cxLink backup. In the example, database DBD will be recovered to local time 2022-01-03-11.46.00:

  • Stop SAP application and deactivate DB2 Database
  • Execute command:
db2 recover db DBD to 2022-01-03-11.46.00 using local time

Command Line Restore using a specific backup image

Backup images are identified by DB2 by timestamp. You can look for a backup image using backup history commands or cxLink Backup catalog and restore it.

Following example would restore DBD database backup image with timestamp 20220104122907:

db2 restore db DBD load /opt/emory/lib/libemorydb2.so taken at 20220104122907

Command Line Restore using incremental backup images

You can execute a restore operation using a full backup (online or offline) and subsequent incremental/delta.

You can do it automatically letting DB2 to determine which backup images to restore or manually using DB2 utility db2ckrst.

For example, to restore an incremental backup of DBD database with timestamp 20220104124230, next steps would be performed:

  • Execute:
db2ckrst -d DBD -t 20220104124230

DB2 will calculate backup images to be restored and order:

Suggested restore order of images usgin timestamp 20220104124230 for database DBD.
====================================================================
 restore db DBD incremental taken at 20220104124230
 restore db DBD incremental taken at 20220104122907
 restore db DBD incremental taken at 20220104124230
====================================================================
  • Execute suggested commands specifying that cxLink Backup library is to be used:
db2 restore db DBD incremental load /opt/emory/lib/libemorydb2.so taken at 20220104124230
db2 restore db DBD incremental load /opt/emory/lib/libemorydb2.so taken at 20220104122907
db2 restore db DBD incremental load /opt/emory/lib/libemorydb2.so taken at 20220104124230

Note: replace existing has been added to avoid prompt asking to replace the database as we are restoring same database SID.

  • Execute corresponding rollforward operation to desired point in time or log and start database

DB2 High Availability

When you configure your DB2 database to be HA, some configuration has to be done to have a common backup objects catalog for all your cluster nodes.

It consists in activate HA for DB2 from CxLink Backup and to define a shared location between your nodes to be used to save backup objects catalog.

Prerequisites

A shared filesystem over all your cluster nodes.

Go to Configuration for DB2:

? CxLink Backup:  [Use arrows to move, enter to select, type to filter]
  --------------------------------------------------------------------------------
  Storage Providers profiles
  Set storage providers for backup/restore, disaster recovery and system copy
> Configuration for DB2
  Backups Lifecycle settings
  Monitoring
  --------------------------------------------------------------------------------
  License
  --------------------------------------------------------------------------------
  Logging file settings
  Debug traces
  Show relevant information of this CxLink Backup
  --------------------------------------------------------------------------------
  Catalog & Backups management
  --------------------------------------------------------------------------------
  Generate troubleshooting package to be sent to Syntax Support
  Migrate resources to last models
  --------------------------------------------------------------------------------
  Exit

Access to Set HA Configuration:

? CxLink Backup: Configuration for DB2
? Select action to perfom:   [Use arrows to move, enter to select, type to filter]
> Set HA Configuration
  Back

Activate the HA option:

? CxLink Backup: Configuration for DB2
? Select action to perfom:  Set HA Configuration
? Enable DB2 HA configuration? (Y/n) y

And define a shared location to save catalog:

? CxLink Backup: Configuration for DB2
? Select action to perfom:  Set HA Configuration
? Enable DB2 HA configuration? Yes
? HA shared directory: (/opt/emory/db2ha)

Note: /opt/emory/db2ha is just an example, you can configure your own HA shared directory

You can also configure DB2 HA using the command line.

Activate HA:

/opt/emory/emory datasource ha true

Define a shared location:

/opt/emory/emory datasource shared-dir /opt/emory/db2ha

Note: /opt/emory/db2ha is just an example, you can configure your own HA shared directory

Where are your backups stored?

They will be stored in the target bucket as:

<DB2_INSTANCE>/<DB>/<year>/<month>/<day>/<timestamp>.<db_sid>.<full|incremental|delta|archive>.<DB2_instance>.<database_partition>.<sequence_number>

Example: db2dbd/DBD/2022/02/25/20220225093619.DBD.FULL.db2dbd.DBPART000.001

WARNING

Backups executed prior to release 2304.11 Kimchi are stored in:

<SAPSYSTEMNAME>/<DB>/<year>/<month>/<day>/<timestamp>.<db_sid>.<full|incremental|delta|archive>.<SAPSYSTEMNAME>.<database_partition>.<sequence_number>