Oracle rman备份还原

  备份脚本:

 oracle备份fullbak.sh 脚本

. /u01/prod/db/12.1.0/PROD_erpdbp.env
LOGDATE="`date '+%Y%m%d'`"
#delete backup logfile
find /u01/backup/log -mtime +360 |xargs rm -f
rman target / cmdfile=/u01/backup/scripts/fullbak.rman log=/u01/backup/log/fullbak_$LOGDATE.log
 
rman备份脚本fullbak.rman:
run{
sql 'alter system archive log current';
      allocate channel ch1 type disk;
      allocate channel ch2 type disk;
      allocate channel ch3 type disk;
      backup as compressed backupset incremental level 0 database format '/u01/backup/data/db_%d_%T_%U.bak' plus archivelog format '/u01/backup/data/arch_%d_%T_%U.bak' delete all input; 
      CONFIGURE CONTROLFILE AUTOBACKUP on; 
      release channel ch1;
      release channel ch2;
      release channel ch3;
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete expired archivelog all;
report obsolete;
delete noprompt obsolete;
}

RMAN 还原:

查看oracle的控制文件备份信息:
list backup of controlfile;
用rman恢复数据:
 1,startup nomount;
 2,set dbid= 365215955;
 3,restore controlfile from '/u01/bak/db_PROD_20190807_41u8j1iv_1_1.bak';
 4,startup mount;
5,catalog start with '/u01/bak/';
 6,restore database
 7,recover database;
 8,alter database open resetlogs;

这里的 set dbid= 365215955 要和主库的一致 ,查看主库sql: select dbid from v$database;

 
recover database until scn 5971330707288;
 
create undo tablespace undotb2 datafile '/u01/prod/db/data/undotb12.dbf' 
size 1024M autoextend on next 10M maxsize 12048M;
 
提示错误:
ORA-30012: undo tablespace 'UNDOTBS1' does not exist or of wrong type
 
强制打开数据库:
startup force;
重新创建undo表空间
create undo tablespace undotb2 datafile '/u01/prod/db/data/undotb12.dbf' size 1024M autoextend on next 10M maxsize 12048M
在设置spfile文件
alter system set undo_tablespace=undotb2 scope=spfile;
修改undo的管理模式
alter system set undo_management=auto scope=spfile;
创建undo的表空间文件
create undo tablespace undotb2 datafile '/u01/prod/db/data/undotb12.dbf' size 1024M autoextend on next 10M maxsize 12048M

你可能感兴趣的:(Oracle rman备份还原)