ITPub博客

首页 > 数据库 > Oracle > rman 异机恢复脚本(路径不一致)

rman 异机恢复脚本(路径不一致)

原创 Oracle 作者:shawnloong 时间:2015-07-17 13:55:55 0 删除 编辑
由于之前写rman 脚本的时候需要手动去修改一些路径很麻烦,没办法做此脚本方便大家。注此脚本使用前提数据库已经mount,也就是已经恢复了参数文件及控制文件

点击(此处)折叠或打开

  1. #Decription: general rman scription
  2. #Author by:netdata
  3. #Date:2015-07-17
  4. #!/bin/bash
  5. $ORACLE_HOME/bin/sqlplus -s " / as sysdba" <<eof >file1.log
  6. set head off;
  7. set feedback;
  8. select name from v\$datafile;
  9. exit;
  10. eof
  11. #
  12. for file in `cat file1.log`; do
  13.   file=`basename $file`;
  14.   echo "'"'/oradata/xyxdb/xyxdb/'$file"'">>newfile.log;
  15. done
  16. #
  17. for file in `cat file1.log`; do
  18.   echo "'"$file"'">>newfile1.log;
  19. done
  20. #
  21. while read -u3 i && read -u4 j;do
  22.   echo " set newname for datafile "$i" to "$j";">>rman1.log;
  23. done 3<newfile1.log 4<newfile.log
  24. #
  25. $ORACLE_HOME/bin/sqlplus -s " / as sysdba" <<eof >maxsn.log
  26. set head off;
  27. set feedback;
  28. select * from (select next_change# from v\$archived_log order by next_change# desc) where rownum=1;
  29. exit;
  30. eof
  31. #
  32. #生成rman脚本
  33. max_sn=`sed -e 's/^[ \t]*//g' maxsn.log | grep -v '^$'`
  34. echo $max_sn
  35. awk 'BEGIN{print"run {"}END{print "restore database;";print "switch datafile all;";print "recover database until scn '$max_sn';";print "}"}1' rman1.log>restore.rman
  36. rm -rf newfile.log newfile1.log rman1.log file1.log
  37. #rman nocatalog target / cmdfile=restore.rman log restore`date +%Y%m%d`.log

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24486203/viewspace-1736180/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-08-29

  • 博文量
    110
  • 访问量
    292642