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

由于之前写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博客 ” ,链接:http://blog.itpub.net/24486203/viewspace-1736180/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24486203/viewspace-1736180/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值