ORACLE不完全备份系列用rman方式基于日志序列的不完全恢复sql>select*fromtest;a-----123456sql>hostramntarget/rman>run{allocatechannelc1typedisk;bakupfulltag'dbful
ORACLE不完全备份系列
用rman方式基于日志序列的不完全恢复
sql> select * from test;
a
-----
1
2
3
4
5
6
sql>host
ramn target/
rman>run
{
allocate channel c1 type disk;
bakup full tag 'dbful' format 'd:\backup\full_%u_%s_%p' database
include current controlfile;
sql' alter system archive log current';
release channel c1;
} www.2cto.com
rman>exit;
sql>insert into test values(16);
sql>commit;
sql>alter system switch logfile;
sql>insert into test values(17);
sql>alter system switch logfile;
sql>archive log list;
....
oldest onlie log sequence 14
next log sequence to archive 16
current log sequence 16
sql>select group#,sequence#,archived,status from v$log
group# sequence# archived status
-----------------------------------
1 16 yes active
2 17 no current
3 15 yes active
从这里看出备份的数据文件包含了第14个归档日志. 在线日志v$log里正在使用的是17序列的日志,15和16已经完成了归档.
当我们没有备份15和16日志.15和16包含了表test新数据16和17.
实现不完全恢复就是只恢复归档日志下面的日志数据. 不能进行实例恢复,也就是说在线日志被看成没了!
在线日志17里的数据不能被恢复, 15和16日志已经被归档,当没备份,如果没有被删除是可以被恢复的.
sql> shutdown immediate;
sql>startup nomount;
sql>alter database monut;
sql>host www.2cto.com
rman target/
rman> run{
allocate channel c1 type disk;
set until logseq 14 thread 1;
restore database;
recover database;
sql'alter database open resetlogs';
}
用rman方式基于时间的不完全恢复
sql> insert into test values(100);
commit;
sql> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
sql> select sysdate from dual;
sysdate
----------
2012-06-15 10:36:14
sql> host
rman target /
rman>run
{
allocate channel c1 type disk;
bakup full tag 'dbful' format 'd:\backup\full_%u_%s_%p' database
include current controlfile;
sql' alter system archive log current';
release channel c1;
}
rman> exit
sql> insert into test values(150);
sql>commit;
sql> select sysdate from dual;
sysdate
----------
2012-06-15 10:46:14
sql>alter system switch logfile;
sql> insert into test values(250);
sql> commit;
sql> select sysdate from dual;
sysdate
----------
2012-06-15 10:50:14
sql> shutdown immediate;
sql> startup mount;
sql> exit;
set nls_date_format=yyyy-mm-dd hh24:mi:ss
rman target/ www.2cto.com
rman>run{
allocate channel c1 type disk;
set until time '2012-06-15 10:46:14';
restore database;
recover database;
sql 'alter database open resetlogs';
release channel c1;
}
--recover database until time '2008-04-10 10:36:14'; 可以不用set until 直接在recover database跟
--set until time "to_date('2008042115:00:00','yyyymmdd hh24:mi:ss')" 可以不用操作
系统设置时间格式
用rman方式基于scn的不完全恢复
sqlplus "/as sysda"
sql>select dbms_flashback.get_system_change_number from dual;
xxxxx345
sql>insert into test values(400);
sql>commit;
sql>select dbms_flashback.get_system_change_number from dual;
xxxxx356;
sql> host;
rman target/
rman>run
{
allocate channel c1 type disk;
bakup full tag 'dbful' format 'd:\backup\full_%u_%s_%p' database
include current controlfile;
sql' alter system archive log current';
release channel c1;
}
rman>exit;
sql>insert into test values(450);
sql>commit;
sql>select dbms_flashback.get_system_change_number from dual;
xxxxx368 www.2cto.com
sql>shutdown immediate;
sql>startup mount;
sql>exit;
rman target/
rman> run{
allocate channel c1 type disk;
restore database;
recover database until scn xxxx356;
sql 'alter database open resetlogs';
release channel c1;
}
作者 ZengMuAnSha