db2数据库还原

db2 数据库 还原命令
 
1.备份的数据库(olddb) 与要还原的数据(newdb)名不相同: 
db2 restore db olddb into newdb; 
2.当前目录下存在多个备份文件.需要指定时间 
db2 restore db olddb taken at 20120819175932 into newdb; 
 
3.需要指定备份文件的目录 
db2 RESTORE DATABASE olddb FROM "/media/olddb.0.db2inst1.NODE0000.CATN0000.20120819175932.001" 
TAKEN AT 20120819175932  INTO newdb; 
 
4.需要指定newdb NEWLOGPATH路径 
db2 RESTORE DATABASE olddb FROM "/media/olddb.0.db2inst1.NODE0000.CATN0000.20120819175932.001" 
TAKEN AT 20120819175932 NEWLOGPATH "/opt/log" WITH 2 BUFFERS BUFFER 1024 INTO newdb; 
5.需要指定表空间的 
1).创建文件夹 
mkdir /home/db2inst1/db2space/newdb_sp0; 
mkdir /home/db2inst1/db2space/newdb_sp1; 
mkdir /home/db2inst1/db2space/newdb_sp2; 
mkdir /home/db2inst1/db2space/newdb_sp3; 
mkdir /home/db2inst1/db2space/newdb_sp4; 
mkdir /home/db2inst1/db2space/newdb_sp5; 
mkdir /home/db2inst1/db2space/newdb_sp6; 
 
2).还原命令加入 redirect without rolling forward 
db2 RESTORE DATABASE olddb FROM "/media/olddb.0.db2inst1.NODE0000.CATN0000.20120819175932.001" 
TAKEN AT 20120819175932 NEWLOGPATH "/opt/log" WITH 2 BUFFERS BUFFER 1024 INTO newdb 
redirect without rolling forward; 
 
3).设置表空间目录 
SET TABLESPACE CONTAINERS FOR 0 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp0"); 
SET TABLESPACE CONTAINERS FOR 1 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp1"); 
SET TABLESPACE CONTAINERS FOR 2 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp2"); 
SET TABLESPACE CONTAINERS FOR 3 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp3"); 
SET TABLESPACE CONTAINERS FOR 4 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp4"); 
SET TABLESPACE CONTAINERS FOR 5 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp5"); 
SET TABLESPACE CONTAINERS FOR 6 IGNORE ROLLFORWARD CONTAINER OPERATIONS USING (PATH "/home/db2inst1/db2space/newdb_sp6"); 
 
3).还原继续.注意为olddb 
RESTORE DATABASE olddb CONTINUE; 
 
6.数据库还原退回 
db2 restore db 注意为olddb abort 
 
7.还原后如果NEWLOGPATH 需要变更的 
db2 UPDATE DB CFG FOR newdb USING NEWLOGPATH /db2/db2inst1/db2logpath 
db2 UPDATE DB CFG FOR newdb  USING LOGFILSIZ 10001 
db2 force applications all; 
db2stop; 
db2start; 


前滚,向着时间增大的方向走,也就是,数据越来越新。

回滚,就是回退,是指对没提交的数据,做回退,恢复到修改之前的状态。

回退的今天13:00,得用今早8:00的备份,加上之后的日志,做前滚。

若回退的昨天早上9:00,得用昨天早上8:00的备份,加上8-9点间的日志做前滚。

你可能感兴趣的:(db2数据库还原)