You can perform a snapshot backup of your Db2 database by using
container commands to momentarily pause 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
- Obtain
the name of the db2ucluster and assign it to a variable:
# oc get db2ucluster
Example result:
NAME STATE MAINTENANCESTATE AGE
db2oltp-1611589677085880 Ready None 46d
Assign the db2cluster name to a
variable:
DB2UCLUSTER_ID=db2oltp-1611589677085880
-
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 that is similar
to the example below:
The authenticity of host '[c-db2oltp-1611589677085880-db2u-0.c-db2oltp-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.
-
Confirm that Db2 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
-
Take the snapshot of the persistent volume claim and volume claim templates at the storage
layer. The steps differ depending on your storage provider:
-
Resume writes to the database:
oc exec -it c-${DB2UCLUSTER_ID}-db2u-0 -- manage_snapshots --action resume
-
Confirm that Db2 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.