Backing up by using the db_backup command
For an IBM® Db2® Warehouse MPP deployment, the IBM recommended backup method for the BLUDB database is to use a Single System View (SSV) backup. This strategy helps you perform a backup of all database partitions simultaneously, including the catalog partition. SSV backups provide a single time-stamp for all database partitions, making the recovery simpler. The backup command can be invoked only from the Catalog node, but each MLN (Multiple Logical Node) participates in the backup operation.
- Run the db_backup command as the
bluadmin
ordatabase admin
user. - In MPP, the db_backup command should be invoked only from the Catalog node.
db2 values current node
If the output of the command shows
a value of 0, you are logged onto the Catalog node.Database backup types
- Full offline backups
- Full online backups
- Incremental online backups
Schema backup types
- Full online backups
- Incremental online backups
- Delta incremental online backups
The db_backup command
Run the db_backup -h command as the bluadmin
or
database admin
user.
For a schema backup to process tables that are enabled for Row and Column Access Control (RCAC),
a user must be granted the LOGICAL BACKUP AND RESTORE OF RCAC PROTECTED DATA privilege. This is not
required for the bluadmin
user.
db_backup -type {off|onl|inc} -path path [-compress {no | yes}] [-comprlib compression_library] [-partitioned-backup]
db_backup -type {off|onl|inc} -tsm [-sessions {1|number}] [-compress {no | yes}] [-comprlib compression_library]
db_backup -type {off|onl|inc} -emc [-compress {no | yes}] [-comprlib compression_library]
db_backup -type {onl|inc|del} -path path -schema schema_name [-schemafile filepath] [-compress {gzip | lz4 | no}] [-format {binary | text}] [-sessions N] [-image-check [hash | size | rowcount]]
db_backup -type {onl|inc|del} -tsm -schema schema_name [-schemafile filepath]
[-compress {gzip | lz4 | no}] [-format {binary | text}] [-sessions N] [-image-check rowcount]`
db_backup -history
db_backup -version
db_backup -status
db_backup {-h|--help}
- -type {off|onl|inc|del}
- The type of backup to run:
- off
- A full offline backup.
- onl
- A full online backup. The default backup image target directory is /mnt/bludata0/db2/archive_log.
- inc
- An incremental online backup. An incremental backup image is a copy of all data that has changed since the most recent, successful, full backup operation. This is also known as a cumulative backup image, because a series of incremental backups taken over time will each have the contents of the previous incremental backup image. The predecessor of an incremental backup image is always the most recent successful full backup of the same object.
- del
- A delta incremental online backup, also known as a differential backup.
- -path path
- A target directory or device. The full path on which the directory resides must be specified.
This target directory or device must be locally addressable on the database server. Multiple paths
can be specified to improve performance.Note:
- In a Db2 Warehouse MPP deployment, the target directory or device must exist on all database partitions.
- The target directory must be owned by the
db2inst1
user or its group.
- -schema schema_name
- Name of the database schema to be backed up. If not specified, the entire database is backed up. The schema names must be separated by a space. For more information, refer to Schema enabled for row modification tracking.
- -compress
- Optional parameter. If specified, the data files in the backup are compressed. When used with -schema option default is set to lz4. When used without the -schema option (database backup), default is set to no.
- -comprlib compression_library
- Indicates the name of the library that is used during the compression or encryption. The name
must be a fully qualified path that refers to a file on the server. If this parameter is not
specified, the default Db2 compression library libdb2compr.so is
used.
Encryption libraries: libdb2encr.so Compression library: libdb2compr.so Encryption and compression libraries: libdb2compr_encr.so
If the specified library cannot be loaded, the backup operation fails.
- -format {text|binary}
- The format the backup files will take. By default, this is set to binary.
- -partitioned-backup
- Directs backup to create separate sub-folder under provided path for each MLN using format 'MLN $4N', where $4N is a 4-digit number of the node.
- -tsm
- The backup directly is to be run to IBM Spectrum Protect. Contact your IBM service representative for assistance.
- -sessions {1|number}
- The number of I/O sessions between IBM Db2 Warehouse and IBM Spectrum Protect or another backup product. This parameter has no effect when you back up to tape, disk, or another local device. The recommended number of sessions is 2; the default number is 1.
- -emc
- The backup directly is to be run to EMC NetWorker. Contact your IBM representative for assistance.
- -schemafile
- Specifies the case-sensitive schema names to backup using a file. Each schema name in the file must be provided in a separate line.
- -history
- Displays up to 10 backup images. If more than 10 backups have been made, information about the latest 10 backups is displayed. The rest of the information is redirected to the /scratch/bluadmin_BNR/backup_history.txt file.
- -status
- Displays if another db_backup or db_restore is in progress. Each job is displayed on a separate line.
- -sessions N
- Optional. Spawns N threads to back up individual tables concurrently. The default value is 4. For multi-schema backups, N threads are spawned for each schema.
- -image-check [hash|size|rowcount]
-
Optional. Post-process schema backup files to enable image integrity verification prior to schema-level restore. All values can be selected. No value is set by default. However, a list of names of all files in backup image is always recorded and verified before restore.
- hash
- Computes and records hash values for all files in a backup image.
- size
- Records sizes of all files in a backup image.
- rowcount
- Processes data files and records the number of rows.
docker exec -it dashDB bash -lc "backup_command_to_execute"
podman exec -it dashDB bash -lc "backup_command_to_execute"
For
example, to run the db_backup command for a full offline backup to a shared
storage path that is mounted at /mnt/external/backup inside the container,
issue the following
command:docker exec -it dashDB bash -lc "db_backup -path /mnt/external/backup -type off"
podman exec -it dashDB bash -lc "db_backup -path /mnt/external/backup -type off"
Backup destinations
The following backup destinations can be used:- SAN storage
- NAS storage
- IBM Spectrum Protect server - LAN Based (v1.0.7.0 or later)
- IBM Spectrum Protect server - LAN Free (v1.0.9.0 or later)
- EMC NetWorker (v1.0.9.0 or later)
Examples
- Full offline
backup:
db_backup -path /mnt/external/Backup-Demo/Off-bkp -type off
- Full offline backup to IBM Spectrum Protect with one
sessions
db_backup -type off -tsm
- Full offline backup to IBM Spectrum Protect with two
sessions:
db_backup -type off -tsm -sessions 2
- Full online
backup:
db_backup -path /mnt/external/Backup-Demo/Onl-bkp -type onl
- Full online backup to IBM Spectrum Protect with one
session:
db_backup -type onl -tsm
- Full online backup to IBM Spectrum Protect with two
sessions:
db_backup -type onl -tsm -sessions 2
- Incremental
online backup:
db_backup -path /backup/Backup-Demo/online-inc -type inc
- Incremental
online backup to IBM Spectrum Protect with one
session:
db_backup -type inc -tsm
- Incremental
online backup to IBM Spectrum Protect with two
sessions:
db_backup -type inc -tsm -sessions 2
- Backup with multiple destination
paths:
db_backup -path /mnt/external/Backup-Demo/Off-bkp/path1,/mnt/external/Backup-Demo/Off-pkp/path2 - type off
- Check backup history:
db_backup -history
- Full offline backup to EMC NetWorker:
db_backup -type off -emc
- Full online backup to EMC NetWorker:
db_backup -type onl -emc
- Incremental
online backup to EMC NetWorker:
db_backup -type inc -emc