当前位置:网站首页>Oracle rman半自动恢复脚本-restore阶段
Oracle rman半自动恢复脚本-restore阶段
2022-07-02 06:24:00 【贤时间】
#!/bin/bash
##############################################
#NAME: rman_auto_restore.sh
#DESC:restore oracle db from prod environment to test environment very quickly.
#Note: Linux USER - execute as oracle instance user
#History:
# v1.0 2022-03-08 yangshixian
##############################################
. /home/${USER}/.bash_profile
#
#define Oracle env 配置EBS环境变量
#
export PATH=/data/ebs/sit/db/tech_st/11.2.0/perl/bin:/data/ebs/sit/db/tech_st/11.2.0/bin:$PATH
export PERL5LIB=/data/ebs/sit/db/tech_st/11.2.0/perl/lib/5.10.0:/data/ebs/sit/db/tech_st/11.2.0/perl/lib/site_perl/5.10.0:/data/ebs/sit/db/tech_st/11.2.0/appsutil/perl
export ORACLE_SID=PROD #针对linux的配置文件中实例名大小写敏感
export ORACLE_HOME=/data/ebs/sit/db/tech_st/11.2.0
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
#
#rman env conf 配置rman环境变量#
#
RMAN_BAK_PATH=/data1/backup/rman_bak_data/
RMAN_CONTROLFILE=`ls $RMAN_BAK_PATH | grep C0_ |head -1`
TARGET_DATA_FILE_PATH=/data/ebs/sit/db/apps_st/data
#
#unmount:execute rman restore scripts
#
echo "restore controlfile begin ..."
rman target / <<EOF run { startup nomount; RESTORE CONTROLFILE FROM '$RMAN_BAK_PATH$RMAN_CONTROLFILE'; alter database mount; catalog start with '$RMAN_BAK_PATH' noprompt; } exit EOF
echo "restore controlfile end Status $?"
#
#mount:execute rman restore scripts
#
echo "gen restore rman_scripts begin ...."
sqlplus -s / as sysdba <<EOF set heading off feed off verify off echo off pages 0 trimspool on set lines 132 pagesize 0 spo restore.rman select 'run{' from dual; select 'set newname for datafile ' || file# || ' to '|| '''' || '$TARGET_DATA_FILE_PATH' || substr(name,INSTR(name,'/',-1,1)) || '''' || ';' from v\$datafile; select 'restore database;' || chr(10) || 'switch datafile all;' || chr(10) || '}' from dual; spo off exit; EOF
echo "gen restore rman_scripts end status $?"
echo "begin rman restore ....."
echo `date`
rman target / log rman_auto_restore_`date -I`.log @restore.rman
echo "begin rman restore over! status: $?"
echo `date`
边栏推荐
- PIP install
- js中map和forEach的用法
- [leetcode question brushing day 35] 1060 Missing element in ordered array, 1901 Find the peak element, 1380 Lucky number in matrix
- SQLI-LABS通关(less6-less14)
- The win10 network icon disappears, and the network icon turns gray. Open the network and set the flash back to solve the problem
- ARP攻击
- Self study table Au
- Tool grass welfare post
- Thinkphp5中一个字段对应多个模糊查询
- js删除字符串的最后一个字符
猜你喜欢
随机推荐
Sqli labs customs clearance summary-page3
SQL注入闭合判断
php中生成随机的6位邀请码
MySQL中的正则表达式
Common function writing method and set get writing method for calculating attributes
AWD learning
DeprecationWarning: . ix is deprecated. Please use. loc for label based indexing or. iloc for positi
The use of regular expressions in JS
sqli-labs通关汇总-page3
Improve user experience defensive programming
MapReduce与YARN原理解析
PXC high availability cluster summary
PgSQL learning notes
SQLI-LABS通关(less2-less5)
数仓模型事实表模型设计
Queue (linear structure)
Basic knowledge of software testing
Flex Jiugongge layout
Date time API details
Eslint configuration code auto format



![[Zhang San learns C language] - deeply understand data storage](/img/b5/cf0bfae8eacf335d3c350c9cbadb87.png)





