DB2 9.7 backup restore

Original db2 9.7 backup recovery (restore)

  • Blog Category:
  • db2

db2 backup restore backup restore rollforward 


Similar to Windows under linux,
you may encounter many problems when restoring, but the backup is actually very simple

 

The database and log should be backed up when backing up, because the log is used when rolling forward.
If the include logs parameter is not used during backup, the logs should be backed up separately
. Generally, the backup with the include logs parameter is simpler.

 

1. Offline backup
 can only do offline backup by default
1. Disconnect
--db2 connect to sample
--db2 list applications for db sample
db2 force applications all
--db2stop force  
--db2start

 

2. Offline backup
db2 backup db sample to D:\backup\db\db2\sample\offline
The backup is successful. The timestamp of this backup image is: 20141015143312
Filename : SAMPLE.0.DB2.NODE0000.CATN0000.20141015143312.001

Offline backup does not support this parameter
include logs
SQL2032N "iOptions" parameter is invalid.

 

3. View backup history
db2 list history backup all for sample

 

4.恢复
db2 restore db sample from "D:\backup\db\db2\sample\offline" taken at 20141015143312

 

5. Rollforward
-- view
--db2 rollforward db sample
rollforward
db2 rollforward db sample complete
or
db2 rollforward db sample stop
--db2 rollforward db sample to end of logs
--SQL1268N due to retrieving database "SAMPLE on node "0" "The log file "S0000000.LOG"
-- error "1" occurred, rollforward recovery stopped.

 

2. Online backup

To do online backup, you need to modify the parameters userexit and logretain to
view the existing parameter configuration
db2 get db cfg for sample

 

db2 update db cfg for sample using userexit on //enable user exit   
db2 update db cfg for sample using logretain on //enable archive log   
db2 update db cfg for sample using trackmod on //enable incremental backup function 

 

(Every Node needs to be set separately, currently there is only one Node)
After these parameters are enabled, the database is in backup pending state, and an offline full backup of the database is required.
To do an offline full backup, refer to the above command.

 

1. Online full backup
db2 backup database sample online to D:\backup\db\db2\sample\online include logs
was successfully backed up. The timestamp of this backup image is: 20141015143758 (point in time 1)

 

2. Online cumulative incremental backup
Backup the changed part after the last online full backup
db2 backup database sample online incremental to D:\backup\db\db2\sample\incremental include logs
The backup was successful. The timestamp of this backup image is: 20141015143921 (point in time 2)

 

3. Online differential incremental backup
Backup the changed part after the last online backup
db2 backup database sample online incremental delta to D:\backup\db\db2\sample\delta include logs
The backup was successful. The timestamp of this backup image is: 20141015143955 (point in time 3)


3. Recovery


1. Restore online full backup only to (time point 1)
--db2 drop db sample
db2 restore db sample from "D:\backup\db\db2\sample\online" taken at 20141015143758 logtarget D:\backup\db\db2 \sample\backupdblogs
rollforward
db2 rollforward db sample to end of logs and complete overflow log path(D:\backup\db\db2\sample\backupdblogs) noretrieve
logtarget Specifies the log output directory, any one, before (single) recovery to clear first

 

2. Restore cumulative incremental backup only to (time point 2)
--db2 drop db sample
db2 restore db sample incremental automatic from "D:\backup\db\db2\sample\incremental" taken at 20141015143921 logtarget D:\backup\ When db\db2\sample\backupdblogs
is restored, the automatic parameter is specified, and it will automatically restore the previous relevant backup (full backup) . db2 rollforward db sample to end of logs and complete overflow log path(D:\backup\db\
db2
\sample\backupdblogs) noretrieve

 

3. Restore differential incremental backup only to (time point 3)
--db2 drop db sample
db2 restore db sample incremental automatic from "D:\backup\db\db2\sample\delta" taken at 20141015143955 logtarget D:\backup\ db\db2\sample\backupdblogs
rollforward
db2 rollforward db sample to end of logs and complete overflow log path(D:\backup\db\db2\sample\backupdblogs) noretrieve

 

4. Restoration without automatic parameters
It is recommended to use automatic parameters when restoring, which is simple

View the operation to restore to a certain timestamp (db2 recommended order)
db2ckrst -d sample -t 20141015143955 -r database
generally restore the latest backup (time point 3)
and then restore (time point 1)
and then restore (time point 2)
Then restore the latest backup (time point 3)

 

删除logtarget目录里的日志
--db2 drop db sample
db2 restore db sample incremental from "D:\backup\db\db2\sample\delta" taken at 20141015143955 logtarget D:\backup\db\db2\sample\backupdblogs


db2 restore db sample incremental from "D:\backup\db\db2\sample\incremental" taken at 20141015143921 logtarget D:\backup\db\db2\sample\backupdblogs


db2 restore db sample incremental from "D:\backup\db\db2\sample\online" taken at 20141015143758 logtarget D:\backup\db\db2\sample\backupdblogs


db2 restore db sample incremental from "D:\backup\db\db2\sample\delta" taken at 20141015143955 logtarget D:\backup\db\db2\sample\backupdblogs

 

Among them, the choice is
SQL2580W warning! Restore these logs to a path containing existing log files. Attempt to overwrite existing day during recovery

log files will cause the restore operation to fail.
Want to continue? (y/n) y

 

前滚
db2 rollforward db sample to end of logs and complete overflow log path(D:\backup\db\db2\sample\backupdblogs) noretrieve

 

Error handling
SQL2574N The backup image restored as part of an incremental RESTORE operation cannot be newer than the target image.
Restore in the order recommended by db2

 

db2 rollforward db sample to end of logs and complete
SQL1119N The database "SAMPLE" cannot be connected or activated because a previous restore was incomplete or still in progress.
SQLSTATE=57019
Delete the database, refer to the above two recovery methods to restore



SQL1268N Rollforward recovery stopped due to error "1" while retrieving log file "S0000001.LOG" for database "SAMPLE" on node "0" .
Logs are required when rolling forward

 

Other
db2 rollforward db sample to 2014-10-15-02.50.40.000000 and stop
db2 rollforward db sample to 2014-10-15-02.50.40.000000 and complete
Check the image with db2ckbkp -h and see if the include log option is 1

 

Similar to backup and recovery of tablespaces, add the clause TABLESPACE ( tablespace-name ). Tablespace level backup/restore operations require the database to be in archivelog and incremental backup mode enabled.

 

The backup scheme I use is
online full backup on the 1st of each month,
online cumulative incremental backup on other days,
so the recovery is simple

 

refer to:

DB2 backup and restore database stepshttp:
//database.51cto.com/art/200709/56545.htm
DB2 offline and online full backup, incremental backup and restore operation stepshttp
://www.chinaunix.net/old_jh/22 /99296.html
DB2 database backup and recovery  summaryhttp:
//mmz06.blog.163.com/blog/static/12141696201011324632710/ 

 

DB2 V9.7 Information Center

http://www-01.ibm.com/support/knowledgecenter/#!/SSEPGG_9.7.0/com.ibm.db2.luw.kc.doc/welcome.html

 

Detailed explanation of DB2 rollforward command usage

http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-1003wucx/

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325851158&siteId=291194637