Database recovery methods

 Backup and recovery

Following, there are four utilities supported within Db2 to facilitate backing up and restoring a database:

The backup utility

The restore utility

The roll-forward utility

The recover utility

 The backup utility:

The backup utility is used to create images outside the database that can be used to recover the entire database or a portion of it. If the database is an archive logging enabled database, the backup utility can be executed online with multiple concurrent applications connected to the database. The backup utility uses the utility heap to copy the data from the table spaces to the backup image. The utility heap can be controlled via the database configuration parameter UTIL_HEAP_SZ.

The backup utility can write the backup image to storage devices on the database server, to a tape device, or can copy the data directly to the TSM storage devices or another vendor-supplied routine.

Execute the BACKUP command to start the backup process. The basic syntax is as follows:

BACKUP [DATABASE | DB] [DatabaseAlias]

<USER [UserName] <USING [Password]>>

<TABLESPACE ([TbspNames]) | NO TABLESPACE>

<ONLINE>

<INCREMENTAL <DELTA>>

<TO [Location] | USE TSM <OPTIONS [TSMOptions]>>

<WITH [NumBuffers] BUFFERS>

<BUFFER [BufferSize]>

<PARALLELISM [ParallelNum]>

<COMPRESS>

<UTIL_IMPACT_PRIORITY [Priority]>

<INCLUDE LOGS | EXCLUDE LOGS>

<WITHOUT PROMPTING>

Take a look at the following commands used in the preceding query:

DatabaseAlias: This command identifies the name assigned to the database from which to create a backup image

UserName: This command identifies the name assigned to a specific user who is to perform the backup operation

Password: This command identifies the password that corresponds to the name of the user who is to perform the backup operation

TbspName: This command identifies the name assigned to one or more specific table spaces to create backup images

Location: This command identifies the directory or device in which to store the backup image that's been created

TSMOptions: This command identifies options that the TSM is to use during the backup operation

NumBuffers: This command identifies the number of buffers to use to perform the backup operation

BufferSize: This command identifies the size, in pages, of each buffer used to perform the backup operation

ParallelNum: This command identifies the number of table spaces that can be read in parallel during the backup operation to improve the performance of the operation

Priority: This command is used to throttle the backup utility to control the effects on concurrent database activity; you can assign this parameter a numerical value within the range of 1 to 100, with 100 representing the highest priority and 1 representing the lowest

If you want to back up the entire database SAMPLE online to TSM, use the following command:

 

BACKUP DATABASE sample ONLINE USE TSM WITH BUFFER 8192 PARALLELISM 8 COMPRESS;

If you want to back up two table spaces, TS_DATA_4K and TS_INDX_4K, of the database SAMPLE online to TSM, use the following command:

BACKUP DATABASE sample TABLESPACE (TS_DATA_4K, TS_INDX_4K) ONLINE USE TSM WITH BUFFER 8192 PARALLELISM 8 COMPRESS;

If you only want to backup the database metadata, such as the history file, without backing up any table spaces, you can use the following command:

BACKUP DATABASE sample NO TABLESPACE;

Backup successful. The timestamp for this backup image is: 20180526232357

The following command can then be used to restore the metadata backup image:

RESTORE DATABASE sample TAKEN AT 20180526232357 REPLACE HISTORY FILE;

You can backup and restore from a 32-bit level database to a 64-bit level database without any change to the RESTORE command. If you want to restore a 32-bit database instance's compressed backup image onto a 64-bit instance, you can specify the comprlib libdb2compr.so compression library within the RESTORE DATABASE command. The EXPORT, INSPECT, CREATE INDEX, CREATE TABLE, ALTER TABLE, DROP TABLE, and DROP INDEX commands are compatible with online backups.

IMPORT with REPLACE, LOAD with COPY NO and ALLOW READ ACCESS, ALTER TABLESPACE ... AUTORESIZE, and REORG TABLE are not compatible with online backups. There is no difference between an ESE database backup operation and a pureScale database backup operation. In a database partitioning feature (DPF), also known as a massively parallel processing (MPP) database, you can use the DBPARTITIONNUMS clause within the BACKUP DATABASE command to backup multiple partitions at the same time. If no partition is specified, the backup utility runs on all the partitions.

Incremental and delta backups:

An incremental backup is a backup image that contains only pages that have been updated since the previous backup image was made. Two types of incremental backup images can be produced: incremental and delta. An incremental backup image is a copy of all database data that has changed since the most recent successful full backup image was created. The predecessor of an incremental backup image is always the most recent successful full backup image of the same object. A delta backup image, however, is a copy of all database data that has changed since the last successful backup (full, incremental, or delta) of the database or table space.

Comments

Popular posts from this blog

Db2 export command example using file format (del , ixf)

How to fix DB2 Tablespace OFFLINE state issue?

Phases of a load operation