当前位置:网站首页>Oracle RMAN automatic recovery script (migration of production data to test)
Oracle RMAN automatic recovery script (migration of production data to test)
2022-07-02 07:05:00 【Virtuous time】
If the production environment migrates data to the test environment , Often need to use rman Backup for recovery .
At the advanced level, there are commercial backup and recovery tools , stay UI Click on the interface to restore the production data to the test environment , The following script is for the poor , Configure environment variables and rman Backup storage location , Just run the script .
#!/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
#Use: nohup ./rman_auto_restore.sh > ./rman_auto_restore.sh.log &
#History:
# v1.0 2022-03-08 yangshixian
##############################################
. /home/${
USER}/.bash_profile
#
#define Oracle env To configure EBS environment variable
#
export ORACLE_SID=XXXPROD # in the light of linux The instance name in the configuration file of is case sensitive
export ORACLE_HOME=/u01/app/xxxx # Target environment ORACLE_HOME route
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PERL5LIB=$ORACLE_HOME/perl/lib/5.10.0:$ORACLE_HOME/perl/lib/uate_perl/5.10.0:$ORACLE_HOME/appsutil/perl
export PATH=$ORACLE_HOME/perl/bin:$ORACLE_HOME/bin:$PATH
#
#rman env conf To configure rman environment variable #
#
RMAN_BAK_PATH=/data/ebs_rman_data/ #rman Absolute path for storing backup files
RMAN_CONTROLFILE=`ls $RMAN_BAK_PATH | grep C0_ |head -1` # Absolute path of control file
TARGET_DATA_FILE_PATH=/data/ebs/uat/db/apps_st/data # Target environment data file location
#
#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) || 'recover database until scn '|| controlfile_change# || ';' || chr(10) || '}' from v\$database; 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`
To be improved
Script to be improved , Just completed the time-consuming recovery part , It can be improved later , For example, if the path of the online log is inconsistent with the production, you need to change the path , After the change, it still needs to be done alter database open resetlogs;
Some also need to rename the database , These can be realized by automatic script .
边栏推荐
- 2021-07-19c CAD secondary development creates multiple line segments
- ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
- The boss said: whoever wants to use double to define the amount of goods, just pack up and go
- Sqli labs customs clearance summary-page1
- Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix
- 解决微信小程序swiper组件bindchange事件抖动问题
- MySQL index
- Oracle APEX 21.2 installation et déploiement en une seule touche
- php中根据数字月份返回月份的英文缩写
- JS countdown case
猜你喜欢

oracle apex ajax process + dy 校验

Latex warning: citation "*****" on page y undefined on input line*

Sentry construction and use

Solve the problem of bindchange event jitter of swiper component of wechat applet

PgSQL learning notes

How to call WebService in PHP development environment?

Date time API details

Build FRP for intranet penetration

外币记账及重估总账余额表变化(下)

Take you to master the formatter of visual studio code
随机推荐
MapReduce与YARN原理解析
The use of regular expressions in JS
SQLI-LABS通關(less6-less14)
The default Google browser cannot open the link (clicking the hyperlink does not respond)
php中时间戳转换为毫秒以及格式化时间
搭建frp进行内网穿透
pySpark构建临时表报错
Overload global and member new/delete
UEditor . Net version arbitrary file upload vulnerability recurrence
Yolov5 practice: teach object detection by hand
MySQL index
图解Kubernetes中的etcd的访问
ORACLE APEX 21.2安裝及一鍵部署
2021-07-05C#/CAD二次开发创建圆弧(4)
ORACLE 11G SYSAUX表空间满处理及move和shrink区别
Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
Sqli - Labs Clearance (less6 - less14)
Oracle段顾问、怎么处理行链接行迁移、降低高水位
Cloud picture says | distributed transaction management DTM: the little helper behind "buy buy buy"
Sqli-labs customs clearance (less1)