IBM Performance Management

Enabling online backup of the DB2 databases

By default, the Performance Management DB2® databases are configured for offline backup, which means that you must stop the applications that access the databases before you run this backup. You can enable an online backup of the DB2 databases to run in the background. While the online backup is running, applications can continue to access the database so no downtime occurs.

About this task

Several backup options are available for Performance Management DB2 databases, so the solution that is included in this task might require modification for specific environments.

To enable online backup, modify the database configuration. DB2 provides several options for backup. The example specifies a configuration for full backup. Full backup requires substantial disk space and takes more time because the entire database is being backed up each time. DB2 provides a means for incremental backup that has several options.
You can use the following DB2 configuration parameters for online backup configuration. All these parameters are optional except the LOGARCHMETH1, which is mandatory.
LOGARCHMETH1
This mandatory parameter specifies the media type. Change the drive that is specified on this property to an appropriate directory.
AUTO_DEL_REC_OBJ
This optional parameter specifies whether database log files, backup images, and load copy images must be deleted when their associated recovery history file entry is pruned.
REC_HIS_RETENTN
This optional parameter specifies the number of days that historical information about backups is retained.
NUM_DB_BACKUPS
This optional parameter specifies the number of full database backups to retain for a database.
LOGARCHCOMPR1
This optional parameter specifies whether the log files that are written to the primary archive destination for logs are compressed.

Procedure

  1. To configure the SCR32 database for online backup, run the following command as the db2apm user. The directory path in the following command is for example purposes only. The DB2 administrator can choose the directory to contain the database logs.
    mkdir -p /db2_dir/logs/SCR32/archive
    where db2_dir is the directory that contains all the database log files. Start the DB2 Command Line Processor (command db2) and run the following DB2 commands:
    CONNECT TO SCR32;
    UPDATE DB CFG FOR SCR32 USING LOGARCHMETH1 'DISK:/<db2_dir>/logs/SCR32/archive';
    UPDATE DB CFG FOR SCR32 USING AUTO_DEL_REC_OBJ ON;
    UPDATE DB CFG FOR SCR32 USING REC_HIS_RETENTN 10;
    UPDATE DB CFG FOR SCR32 USING NUM_DB_BACKUPS 10;
    UPDATE DB CFG FOR SCR32 USING LOGARCHCOMPR1 OFF;
    DISCONNECT CURRENT;
  2. To configure the WAREHOUS database for online backup, run the following DB2 command as the db2apm user. The directory path in the following command is for example purposes only. The DB2 administrator can choose the directory to contain the database logs.
    mkdir -p /db2_dir/logs/WAREHOUS/archive
    Start the DB2 Command Line Processor (command db2) and run the following commands:
    CONNECT TO WAREHOUS;
    UPDATE DB CFG FOR WAREHOUS USING LOGARCHMETH1 'DISK:/<db2_dir>/logs/WAREHOUS/archive';
    UPDATE DB CFG FOR WAREHOUS USING AUTO_DEL_REC_OBJ ON;
    UPDATE DB CFG FOR WAREHOUS USING REC_HIS_RETENTN 10;
    UPDATE DB CFG FOR WAREHOUS USING NUM_DB_BACKUPS 10;
    UPDATE DB CFG FOR WAREHOUS USING LOGARCHCOMPR1 OFF;
    DISCONNECT CURRENT;
  3. To configure the DATAMART database for online backup, run the following DB2 commands as the db2apm user. The directory path in the following command is for example purposes only. The DB2 administrator can choose the directory to contain the database logs.
    mkdir -p /db2_dir/logs/DATAMART/archive
    Start the DB2 Command Line Processor (command db2) and run the following commands:
    CONNECT TO DATAMART;
    UPDATE DB CFG FOR DATAMART USING LOGARCHMETH1 'DISK:/<db2_dir>/logs/DATAMART/archive';
    UPDATE DB CFG FOR DATAMART USING AUTO_DEL_REC_OBJ ON;
    UPDATE DB CFG FOR DATAMART USING REC_HIS_RETENTN 10;
    UPDATE DB CFG FOR DATAMART USING NUM_DB_BACKUPS 10;
    UPDATE DB CFG FOR DATAMART USING LOGARCHCOMPR1 OFF;
    DISCONNECT CURRENT;
  4. Run an initial offline database backup after you configure the database for online backup. Stop the processes that use the databases. To run the initial offline backup, run the following commands:
    1. As a root user, run the following commands:
      apm stop_all
      apm start db2
    2. As the db2apm user, run the following commands:
      db2 backup db SCR32 to /dev/null
      db2 backup db WAREHOUS to /dev/null
      db2 backup db DATAMART to /dev/null
    3. As the root user, run the following command:
      apm start_all

Results

The databases are now ready for online backup.