恢复测试

对数据文件的指定时间恢复测试

环境:oracle  11.2.0.1

1.创建表t04
  create table t04 as select * from t01;
  
  当前存在的表 t03\t04

2.备份全库
  backup as compressed backupset database format '/home/oracle/bak_dir/whole_%d_%U';
  
  tag=TAG20170605T134710
  
3.切换归档日志
  sql 'alter system archive log current';
  
4.系统时间
  SQL> alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
  SQL> select  sysdate from dual;
    SYSDATE
    -------------------
    2017-06-05 13:51:15

5.删除t04
  drop table t04

6.备份全库
  backup as compressed backupset database format '/home/oracle/bak_dir/whole_%d_%U';
  
  tag=TAG20170605T135412
  
7.使数据文件离线

  RMAN>  sql 'alter database datafile 6 offline';
  
8.删除数据文件
  [oracle@Oracle02 orcl]$ rm -f clinics01.dbf
  
9.恢复
    run{
    sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
    restore datafile 6  from tag=TAG20170605T134710;
    recover datafile 6  until time '2017-06-05 13:51:10';
    sql 'alter database datafile 6 online';
    }

结论: t04表仍不存在,数据文件仍然会被恢复到删除t04表后的时间。对单个文件指定时间点恢复失败

对整库指定时间恢复

1.查看备份集

    RMAN> list backup summary;
    List of Backups
    ===============
    Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
    ------- -- -- - ----------- --------------- ------- ------- ---------- ---
    656     B  F  A DISK        26-MAY-17       1       1       NO         TAG20170526T233019
    657     B  F  A DISK        26-MAY-17       1       1       NO         TAG20170526T233019
    659     B  A  A DISK        26-MAY-17       1       1       NO         TAG20170526T233127
    660     B  F  A DISK        26-MAY-17       1       1       NO         TAG20170526T233128
    661     B  A  A DISK        27-MAY-17       1       1       NO         TAG20170527T233004
    663     B  F  A DISK        27-MAY-17       1       1       NO         TAG20170527T233019
    664     B  F  A DISK        27-MAY-17       1       1       NO         TAG20170527T233019
    666     B  A  A DISK        27-MAY-17       1       1       NO         TAG20170527T233127
    667     B  F  A DISK        27-MAY-17       1       1       NO         TAG20170527T233129
    669     B  A  A DISK        28-MAY-17       1       1       NO         TAG20170528T233003
    670     B  F  A DISK        28-MAY-17       1       1       NO         TAG20170528T233019
    671     B  F  A DISK        28-MAY-17       1       1       NO         TAG20170528T233019
    673     B  A  A DISK        28-MAY-17       1       1       NO         TAG20170528T233127
    674     B  F  A DISK        28-MAY-17       1       1       NO         TAG20170528T233128
    675     B  A  A DISK        29-MAY-17       1       1       NO         TAG20170529T233003
    676     B  A  A DISK        29-MAY-17       1       1       NO         TAG20170529T233003
    677     B  F  A DISK        29-MAY-17       1       1       NO         TAG20170529T233019
    678     B  F  A DISK        29-MAY-17       1       1       NO         TAG20170529T233019
    679     B  F  A DISK        29-MAY-17       1       1       NO         TAG20170529T233019
    680     B  A  A DISK        29-MAY-17       1       1       NO         TAG20170529T233127
    681     B  F  A DISK        29-MAY-17       1       1       NO         TAG20170529T233128
    682     B  A  A DISK        30-MAY-17       1       1       NO         TAG20170530T233003
    683     B  A  A DISK        30-MAY-17       1       1       NO         TAG20170530T233003
    684     B  F  A DISK        30-MAY-17       1       1       NO         TAG20170530T233018
    685     B  F  A DISK        30-MAY-17       1       1       NO         TAG20170530T233018
    686     B  F  A DISK        30-MAY-17       1       1       NO         TAG20170530T233018
    687     B  A  A DISK        30-MAY-17       1       1       NO         TAG20170530T233127
    688     B  F  A DISK        30-MAY-17       1       1       NO         TAG20170530T233128
    689     B  A  A DISK        31-MAY-17       1       1       NO         TAG20170531T233003
    690     B  A  A DISK        31-MAY-17       1       1       NO         TAG20170531T233003
    691     B  F  A DISK        31-MAY-17       1       1       NO         TAG20170531T233019
    692     B  F  A DISK        31-MAY-17       1       1       NO         TAG20170531T233019
    693     B  F  A DISK        31-MAY-17       1       1       NO         TAG20170531T233019
    694     B  A  A DISK        31-MAY-17       1       1       NO         TAG20170531T233127
    695     B  F  A DISK        31-MAY-17       1       1       NO         TAG20170531T233129
    696     B  A  A DISK        01-JUN-17       1       1       NO         TAG20170601T233004
    697     B  A  A DISK        01-JUN-17       1       1       NO         TAG20170601T233004
    698     B  A  A DISK        01-JUN-17       1       1       NO         TAG20170601T233004
    699     B  F  A DISK        01-JUN-17       1       1       NO         TAG20170601T233020
    700     B  F  A DISK        01-JUN-17       1       1       NO         TAG20170601T233020
    701     B  F  A DISK        01-JUN-17       1       1       NO         TAG20170601T233020
    702     B  A  A DISK        01-JUN-17       1       1       NO         TAG20170601T233129
    703     B  F  A DISK        01-JUN-17       1       1       NO         TAG20170601T233130
    704     B  A  A DISK        02-JUN-17       1       1       NO         TAG20170602T233004
    705     B  A  A DISK        02-JUN-17       1       1       NO         TAG20170602T233004
    706     B  F  A DISK        02-JUN-17       1       1       NO         TAG20170602T233029
    707     B  F  A DISK        02-JUN-17       1       1       NO         TAG20170602T233029
    708     B  F  A DISK        02-JUN-17       1       1       NO         TAG20170602T233029
    709     B  A  A DISK        02-JUN-17       1       1       NO         TAG20170602T233137
    710     B  F  A DISK        02-JUN-17       1       1       NO         TAG20170602T233139
    711     B  A  A DISK        03-JUN-17       1       1       NO         TAG20170603T233004
    712     B  A  A DISK        03-JUN-17       1       1       NO         TAG20170603T233004
    713     B  A  A DISK        03-JUN-17       1       1       NO         TAG20170603T233004
    714     B  F  A DISK        03-JUN-17       1       1       NO         TAG20170603T233031
    715     B  F  A DISK        03-JUN-17       1       1       NO         TAG20170603T233031
    716     B  F  A DISK        03-JUN-17       1       1       NO         TAG20170603T233031
    717     B  A  A DISK        03-JUN-17       1       1       NO         TAG20170603T233139
    718     B  F  A DISK        03-JUN-17       1       1       NO         TAG20170603T233140
    719     B  A  A DISK        04-JUN-17       1       1       NO         TAG20170604T233004
    720     B  A  A DISK        04-JUN-17       1       1       NO         TAG20170604T233004
    721     B  F  A DISK        04-JUN-17       1       1       NO         TAG20170604T233029
    722     B  F  A DISK        04-JUN-17       1       1       NO         TAG20170604T233029
    723     B  F  A DISK        04-JUN-17       1       1       NO         TAG20170604T233029
    724     B  A  A DISK        04-JUN-17       1       1       NO         TAG20170604T233138
    725     B  F  A DISK        04-JUN-17       1       1       NO         TAG20170604T233139

    RMAN> 

    
2.指定时间恢复库        
    run{
        sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
        set until time "to_date('2017-05-31  00:00:00','yyyy-mm-dd hh24:mi:ss')";
        restore database;
        recover database;
        alter database open resetlogs;
    }

结论:对整库可实现指定时间恢复

 

你可能感兴趣的:(恢复测试)