Backing up a Db2 or Db2 Warehouse database online

For a Db2 or Db2 Warehouse deployment, the method for the database backup is to use a Single System View (SSV) backup. This strategy helps you back up all database partitions simultaneously, including the catalog partition. SSV backups provide a single time-stamp for all database partitions, making the recovery simpler. The db2 backup command must be run from the node where the Db2 or Db2 Warehouse database service is deployed.

Before you begin

  • For an online backup, the database is online and accessible to applications during backup. Changes that are made to the database during the backup process are included in the backup.
  • You must identify the Db2 or Db2 Warehouse catalog node and have an SSH connection to the catalog node. For more information, see Preparing to back up or restore Db2 or Db2 Warehouse.
Note:

The commands in this procedure use the environment variable containing the default database name ${DBNAME}. If you have multiple databases, please update the variable value or commands accordingly.

Procedure

  1. From a bash shell on the catalog node, switch to the database instance owner and create the directory to hold the backup images:
    su - db2inst1
    mkdir /backup_dir/backup_nnn
    Where backup_dir is the directory that you create to hold backup images and nnn is an incremental value that puts each backup in a separate subdirectory. The backups can be put into any directory on the cluster that is shared by the container nodes and has sufficient space to hold the backups. If you back up into a different directory, alter these commands as necessary.
  2. Connect to the database.
    db2 connect to ${DBNAME}
  3. Run the online backup:
    db2 backup db ${DBNAME} on all dbpartitionnums online to backup_dir include logs without prompting

    Where backup_dir is the full path to the directory that you created in Step 1.

    The online backup is run and returns a successful result:
    Part  Result
    ----  ------------------------------------------------------------------------
    0000  DB20000I  The BACKUP DATABASE command completed successfully.
    0001  DB20000I  The BACKUP DATABASE command completed successfully.
    0002  DB20000I  The BACKUP DATABASE command completed successfully.
    
    Backup successful. The timestamp for this backup image is : 20190523204048
    The database backup is complete.
  4. Run the following command to copy over the two keystore files from the keystore directory into the backup directory:
    cp ${KEYSTORELOC}/keystore.p12 ${BACKUPDIR}
    cp ${KEYSTORELOC}/keystore.sth ${BACKUPDIR}

    When you restore from an encrypted backup, you will need these two keystore files (keystore.p12 and keystore.sth).

What to do next

For instructions on the recommended restore option, see Using the restore script.