一,环境准备

   全备脚本:

oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_sqloracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_hive_02

1 export TMP=/tmp
2 export TMPDIR=$TMP
3 export ORACLE_BASE=/u01
4 export ORACLE_SID=prod
5 export ORACLE_HOME=/u01/oracle/db_1
6 export ORACLE_TERM=xterm
7 export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
8 export LANG=en_US
9 rman target / log /u01/backup/rman_full.log append<<EOF
10 run
11 {allocate channel c1 type disk;
12 allocate channel c2 type disk;
13 backup database filesperset 4 format '/u01/backup/full_%d_%T_%s_%p';
14 sql 'alter system archive log current';
15 sql 'alter system archive log current';
16 sql 'alter system archive log current';
17 backup archivelog all format '/u01/backup/arch_%d_%T_%s_%p' delete input;
18 backup current controlfile format '/u01/backup/ctl_%d_%T_%s_%p';
19 crosscheck backup;
20 crosscheck archivelog all;
21 delete noprompt obsolete;
22 delete noprompt expired backup;
23 delete noprompt expired archivelog all;
24 }
25 EOF

View Code

   增备脚本:

oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_sqloracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_hive_02

1 export TMP=/tmp
2 export TMPDIR=$TMP
3 export ORACLE_BASE=/u01
4 export ORACLE_SID=prod
5 export ORACLE_HOME=/u01/oracle/db_1
6 export ORACLE_TERM=xterm
7 export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
8 export LANG=en_US
9 rman target / log /u01/backup/rman_full.log append<<EOF
10 run
11 {allocate channel c1 type disk;
12 allocate channel c2 type disk;
13 sql 'alter system archive log current';
14 sql 'alter system archive log current';
15 sql 'alter system archive log current';
16 backup archivelog all format '/u01/backup/arch_%d_%T_%s_%p' delete input;
17 backup current controlfile format '/u01/backup/ctl_%d_%T_%s_%p';
18 crosscheck backup;
19 crosscheck archivelog all;
20 delete noprompt expired backup;
21 delete noprompt expired archivelog all;
22 }
23 EOF

View Code

   实际环境..周日全备,其他增备

   周日全备数据:

   运行全备脚本.........

   周一增备:

   这天的数据写入特别多........


create table test as select * from tab;

   create table a as select * from dba_users; 

   create table scott.emp1 as select * from scott.emp where rownum < 3;

   select * from scott.emp1;
.....未完待续
不停的写.....写......写.....

晚上增备了
sh 增备脚本.sh


    数据故障模拟:

oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_sql_05

      又一次删除:

二,故障发现于处理

  第一步: 首先准备

   进入数据库....

   关闭数据库:>>>> shutdown abort

    启动到nomount状态

    进入备份目录查看最新的备份

    进入rman >>> rman target /

  第二步: 恢复控制文件,启动到数据库mount状态

     restore controlfile from '/u01/backup/ctl_PROD_20190301_724_1';oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_oracle_06

  第三步:  

   找到最新的归档集并注册


RMAN> list backup;
......

RMAN> catalog backuppiece '/u01/backup/arch_PROD_20190301_719_1';
RMAN> catalog backuppiece '/u01/backup/arch_PROD_20190301_721_1';
RMAN> catalog backuppiece '/u01/backup/arch_PROD_20190301_722_1';
RMAN> catalog backuppiece '/u01/backup/arch_PROD_20190301_723_1';


  第四步:

   恢复数据

oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_sql_07

  第五步:

    恢复归档数据


RMAN> recover database;


oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_hive_08

  第六步:

    打开数据库到resetlogs模式(重置redo)


RMAN> alter database open resetlogs;


oracle 备份恢复篇(二)---rman 增备恢复--不完全恢复_hive_09

  第七步:

    重新备份数据