DB2 10.5 for Linux, UNIX, and Windows

Backing up to tape

When you back up your database or table space, you must correctly set your block size and your buffer size. This is particularly true if you are using a variable block size (on AIX®, for example, if the block size has been set to zero).

There is a restriction on the number of fixed block sizes that can be used when backing up. This restriction exists because DB2® database systems write out the backup image header as a 4-KB block. The only fixed block sizes DB2 database systems support are 512, 1024, 2048, and 4096 bytes. If you are using a fixed block size, you can specify any backup buffer size. However, you might find that your backup operation will not complete successfully if the fixed block size is not one of the sizes that DB2 database systems support.

If your database is large, using a fixed block size means that your backup operations might take more time than expected to complete. To improve performance, you can use a variable block size.

Note: When using a variable block size, ensure that you have well tested procedures in place that enable you to recover successfully, including explicitly specified buffer sizes for the BACKUP and RESTORE commands, with backup images that are created using a variable block size.

When using a variable block size, you must specify a backup buffer size that is less than or equal to the maximum limit for the tape devices that you are using. For optimal performance, the buffer size must be equal to the maximum block size limit of the device being used.

Before a tape device can be used on a Windows operating system, the following command must be issued:
db2 initialize tape on device using blksize
Where:
device
is a valid tape device name. The default on Windows operating systems is \\.\TAPE0.
blksize
is the blocking factor for the tape. It must be a factor or multiple of 4096. The default value is the default block size for the device.
Restoring from a backup image with variable block size might return an error. If this happens, you might need to rewrite the image using an appropriate block size. Following is an example on AIX:
   tctl -b 0 -Bn -f /dev/rmt0 read > backup_filename.file
   dd if=backup_filename.file of=/dev/rmt0 obs=4096 conv=sync

The backup image is dumped to a file called backup_filename.file. The dd command dumps the image back onto tape, using a block size of 4096.

There is a problem with this approach if the image is too large to dump to a file. One possible solution is to use the dd command to dump the image from one tape device to another. This will work as long as the image does not span more than one tape. When using two tape devices, the dd command is:
   dd if=/dev/rmt1 of=/dev/rmt0 obs=4096

If using two tape devices is not possible, you might be able to dump the image to a raw device using the dd command, and then to dump the image from the raw device to tape. The problem with this approach is that the dd command must keep track of the number of blocks dumped to the raw device. This number must be specified when the image is moved back to tape. If the dd command is used to dump the image from the raw device to tape, the command dumps the entire contents of the raw device to tape. The dd utility cannot determine how much of the raw device is used to hold the image.

When using the backup utility, you will need to know the maximum block size limit for your tape devices. Here are some examples:

Device Attachment Block Size Limit DB2 Buffer Size Limit (in 4-KB pages)
8 mm scsi 131,072 32
3420 s370 65,536 16
3480 s370 61 440 15
3490 s370 61 440 15
3490E s370 65,536 16
7332 (4 mm)1 scsi 262,144 64
3490e scsi 262,144 64
35902 scsi 2,097,152 512
3570 (magstar MP)   262,144 64
Note:
  1. The 7332 does not implement a block size limit. 256 KB is simply a suggested value. Block size limit is imposed by the parent adapter.
  2. While the 3590 does support a 2-MB block size, you could experiment with lower values (like 256 KB), provided the performance is adequate for your needs.
  3. For information about your device limit, check your device documentation or consult with the device vendor.

Verifying the compatibility of your tape device

On UNIX, Linux, and AIX operating systems only, to determine whether your tape device is supported for backing up your DB2 databases, perform the following procedure:

As the database manager instance owner, run the operating system command dd to read from or write to your tape device. If the dd command succeeds, then you can back up your DB2 databases using your tape device.