I want to add validation for free space before restore a db2 database.
I have the *.001 backup file (compressed).
How do I check the estimate db size of that backup?
I can't estimate because the compression ratio is very diverse. db2ckbkp
doesn't have that data.
Best Answer
It is relatively complicated to do, but it's possible.
If your database has only DMS tablespaces that contain table data, you can use
db2ckbkp -T <backup_file>
alone to get this information:Using
TotalPages
andpage_size
from the main section of the output, you can calculate the total space. (You can ignore theContainer CB
sections that give details for each container in the tablespace).If you have SMS tablespaces that store table data (i.e. not just system- or user-temporary tablespaces), you'll see tablespaces in this output that show
TotalPages: 0
.To calculate the amount of data used by these SMS tablespaces, you will need to dump out all of the information from the backup image using
db2ckbkp -a
. You will get lines like this:OrigSize
shows the amount of uncompressed data in this buffer. The line above shows data from an SMS tablespace; DMS tablespaces will also show lines like this, but theObjectType
will showDMS.TABLESPACE.DATA
.So, if you look for lines where
ObjectType
starts with"Tablespace:
, you can add up theOrigSize
of these lines, and find the additional storage space that all SMS tablespaces will use.