db2 全量+增量备份数据

db2 数据库备份策略
 1. 全量+增量模式
  此策略可以恢复到从全量开始任意一天的数据

 

db2 数据库备份

[db2inst1@localhost backup]$ db2 update db cfg using TRACKMOD on 
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W  One or more of the parameters submitted for immediate modification
were not changed dynamically. For these configuration parameters, all
applications must disconnect from this database before the changes become
effective.
--检查
[db2inst1@localhost backup]$ db2 get db cfg  | grep TRACKMOD  
 Track modified pages                         (TRACKMOD) = ON
--全量备份
 [db2inst1@localhost backup]$ db2 backup db sample to /opt/ibm/db2/backup

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

--数据测试
[db2inst1@localhost backup]$ db2 "create table tmp_tab(id integer ) "
DB20000I  The SQL command completed successfully.
[db2inst1@localhost backup]$ db2 "insert into tmp_tab(id) values(12)"
DB20000I  The SQL command completed successfully.
[db2inst1@localhost backup]$ db2 "select * from tmp_tab"

ID        
-----------
         12

  1 record(s) selected.
 
--增量备份 
  [db2inst1@localhost backup]$ db2 backup db sample incremental to  /opt/ibm/db2/backup

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

--模拟灾难
[db2inst1@localhost backup]$ db2 drop db sample
DB20000I  The DROP DATABASE command completed successfully.

--方法一 (手工恢复,必须对全量文件+增量文件依次恢复)
[db2inst1@localhost backup]$ db2 restore db sample incremental from /opt/ibm/db2/backup taken at 20120209154600
DB20000I  The RESTORE DATABASE command completed successfully.


[db2inst1@localhost backup]$ db2 "connect to sample"
SQL1119N  A connection to or activation of database "SAMPLE" cannot be made
because a previous restore is incomplete or still in progress.  SQLSTATE=57019

[db2inst1@localhost backup]$ db2 restore db sample incremental from /opt/ibm/db2/backup taken at 20120209154203
DB20000I  The RESTORE DATABASE command completed successfully.
[db2inst1@localhost backup]$  db2 "connect to sample"
SQL1119N  A connection to or activation of database "SAMPLE" cannot be made
because a previous restore is incomplete or still in progress.  SQLSTATE=57019
[db2inst1@localhost backup]$ db2 restore db sample incremental from /opt/ibm/db2/backup taken at 20120209154600
DB20000I  The RESTORE DATABASE command completed successfully.


[db2inst1@localhost backup]$  db2 "connect to sample"
SQL1117N  A connection to or activation of database "SAMPLE" cannot be made
because of ROLL-FORWARD PENDING.  SQLSTATE=57019

--前滚数据库,使之可用

[db2inst1@localhost db2inst1]$ db2 ROLLFORWARD DATABASE sample TO END OF LOGS    AND COMPLETE OVERFLOW  LOG PATH '(/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR)'

                                 Rollforward Status

 Input database alias                   = sample
 Number of nodes have returned status   = 1

 Node number                            = 0
 Rollforward status                     = not pending
 Next log file to be read               =
 Log files processed                    =  -
 Last committed transaction             = 2012-02-09-07.46.03.000000 UTC

DB20000I  The ROLLFORWARD command completed successfully.


--方法二 (自动恢复,必须对全量文件+增量文件依次恢复)
[db2inst1@localhost backup]$ db2 restore db sample incremental automatic from /opt/ibm/db2/backup taken at 20120209154600
DB20000I  The RESTORE DATABASE command completed successfully.
[db2inst1@localhost backup]$ db2 ROLLFORWARD DATABASE sample TO END OF LOGS    AND COMPLETE OVERFLOW  LOG PATH '(/home/db2inst1/db2inst1/NODE0000/SQL00001/SQLOGDIR)'

                                 Rollforward Status

 Input database alias                   = sample
 Number of nodes have returned status   = 1

 Node number                            = 0
 Rollforward status                     = not pending
 Next log file to be read               =
 Log files processed                    =  -
 Last committed transaction             = 2012-02-09-07.46.03.000000 UTC

DB20000I  The ROLLFORWARD command completed successfully.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值