Performing a snapshot backup with Db2 Warehouse container commands

You can perform a snapshot backup of your Db2 Warehouse database on Cloud Pak for Data by momentarily pausing operators that perform writes and then taking an online snapshot.

About this task

Snapshot backups have significant advantages over traditional backups. They are completed quickly, regardless of database size, and they allow for fast recovery. Also, snapshots do not affect many database operations, except momentarily pausing operations that perform writes.

Procedure

  1. Obtain the name of the db2ucluster and assign it to a variable:
    # oc get db2ucluster
    Example result:
    
    NAME                       STATE   MAINTENANCESTATE   AGE
    db2wh-1611589677085880   Ready   None               46d
    Assign the db2cluster name to a variable:
    DB2UCLUSTER_ID=db2wh-1611589677085880
  2. Suspend operations on the database:
    oc exec -it c-${DB2UCLUSTER_ID}-db2u-0 -- manage_snapshots --action suspend

    The manage_snapshots command might prompt you with a message similar to the example below:

    The authenticity of host '[c-db2wh-1611589677085880-db2u-0.c-db2wh-1611589677085880-db2u-internal]:50022 ([10.254.13.10]:50022)' can't be established.
    RSA key fingerprint is SHA256:R9/ve/iF4j+2BKunEqEo5PGN19UoCYBsnbHWmEmlrbU.
    RSA key fingerprint is MD5:72:cb:84:3a:fa:36:0c:ed:45:96:1b:cd:f9:d4:67:99.
    Are you sure you want to continue connecting (yes/no)?

    If you see this message, type yes in the shell prompt to enable the script to update the known_hosts file to enable password-less SSH access.

  3. Confirm that Db2 Warehouse high availability monitoring is disabled and the database is suspended by issuing the following command:
    oc exec -it c-${DB2UCLUSTER_ID}-db2u-0 -- wvcli system status
  4. Take the snapshot of the persistent volume claim and volume claim templates at the storage layer. The steps differ depending on your storage provider:
  5. Resume writes to the database:
    oc exec -it c-${DB2UCLUSTER_ID}-db2u-0 -- manage_snapshots --action resume
  6. Confirm that Db2 Warehouse high availability monitoring is re-enabled and the database is taken out of write suspend by issuing the following command:
    oc exec -it c-${DB2UCLUSTER_ID}-db2u-0 -- wvcli system status

What to do next

For instructions on the recommended restore option, see Performing a snapshot restore with Db2 container commands in Db2 Warehouse.