5. Backup Types
Full
Incremental
[Incremental] Delta
NOTE: TRACMOD = YES for incremental backup
6. Backup checks
db2 list history backup since 20110101 for db
dbname
SQL to check last 7 successful backup
SELECT DISTINCT START_TIME,END_TIME,OPERATIONTYPE,
FROM SYSIBMADM.DB_HISTORY
WHERE OPERATION = 'B' AND
SQLCODE IS NULL
ORDER BY START_TIME DESC
FETCH FIRST 7 ROWS ONLY;
db2ckbkp can be used to check backup image
consistency
7. HANDY SQL
Check average and maximum time to perform full backup
(Change operation type to check for other types of backup, N denotes full online backup)
denotes
SELECT DBPARTITIONNUM,
AVG(TIMESTAMPDIFF(4,CHAR(TIMESTAMP(END_TIME) -
TIMESTAMP(START_TIME)))) AS AVG_BTIME_MNS,
MAX(TIMESTAMPDIFF(4,CHAR(TIMESTAMP(END_TIME) -
TIMESTAMP(START_TIME)))) AS MAX_BTIME_MNS
FROM SYSIBMADM.DB_HISTORY
WHERE OPERATION = 'B'
AND OPERATIONTYPE = 'N'
group by DBPARTITIONNUM;
8. Recovery
Types of recovery
Crash Recovery
Version Recovery
Roll-forward Recovery
DB2 provides three commands to perform recovery
Restart
Restore
Recover
9. Crash Recovery
Crash recovery can be performed when transactions
terminates abnormally
Restart database when the database has been stopped
abnormally for eg: power failure (this marks the
database as non accessible)
Crash recovery moves back database to consistent state
either by rolling back or committing in memory
transactions
RESTART DATABASE DBNAME
AUTORESTART = ON, in db cfg allows database
manager to perform crash recovery automatically
10. Restore
Restoring from Offline backup (Version
Recovery)
Simple restore command, specify the timestamp of the target backup image
Restoring from Online backup
Restore operation followed by rollforward to either end of logs or PIT or end of
backup (since v9.5)
Restoring from Incremental backup
Restore the target image (last incremental image)
Restore the full backup image
Restore the rest of the backup images till the last incremental image in correct order as per
requirement
Restore the last incremental image
Use automatic option in the restore command and specify last target
image timestamp and db2 automatically does the above steps
db2ckrst can also be used to check the sequence of images for restore
11. Redirect Restore
Start restore with the redirect option
Define the storage paths using set tablespace
containers command
Continue restoration using the continue option
12. Recover
Another command to perform restore
Provide the timestamp it will automatically
find out the backup images needed and
the logs needed for rollforward
Very useful if you want to perform roll
forward on a full offline backup image and
perform PIT recovery
13. Backup Autonomics
OPEN x sessions
INCLUDE LOGS
COMPRESS (only on tablespaces which are not already
compressed)
Let DB2 decide the other parameters
14. Forget Me Not
Recovery strategy
Time to recover
(RTO)
PIT to recover (RPO)
Backup time
Backup image size
Housekeeping
Check backup image
frequently