当前位置:网站首页>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`
边栏推荐
- php中根据数字月份返回月份的英文缩写
- Sqli-labs customs clearance (less2-less5)
- Record RDS troubleshooting once -- RDS capacity increases dramatically
- How to debug wechat built-in browser applications (enterprise number, official account, subscription number)
- Log - 7 - record a major error in missing documents (A4 paper)
- Solve the problem of bindchange event jitter of swiper component of wechat applet
- js的防抖和节流
- Tool grass welfare post
- [Zhang San learns C language] - deeply understand data storage
- SQLI-LABS通关(less15-less17)
猜你喜欢
A preliminary study on ant group G6
sqli-labs通关汇总-page1
Sentry搭建和使用
Recursion (maze problem, Queen 8 problem)
CVE-2015-1635(MS15-034 )遠程代碼執行漏洞複現
Explanation and application of annotation and reflection
IDEA2020中测试PySpark的运行出错
sqli-labs通关汇总-page2
PgSQL learning notes
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
随机推荐
flex九宫格布局
CAD secondary development object
MySQL index
php中的数字金额转换大写数字
JS judge whether the object is empty
Explanation and application of annotation and reflection
Go common compilation fails
sqli-labs通关汇总-page1
Flex Jiugongge layout
sqli-labs通关汇总-page4
In depth study of JVM bottom layer (IV): class file structure
2021-07-17c /cad secondary development creation circle (5)
In depth study of JVM bottom layer (II): hotspot virtual machine object
JS divides an array into groups of three
Sqli Labs clearance summary - page 2
CSRF攻击
数仓模型事实表模型设计
MySQL中的正则表达式
ORACLE EBS接口开发-json格式数据快捷生成
Sqli-labs customs clearance (less18-less20)