当前位置:网站首页>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 .
边栏推荐
- Take you to master the formatter of visual studio code
- The table component specifies the concatenation parallel method
- ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
- [leetcode question brushing day 35] 1060 Missing element in ordered array, 1901 Find the peak element, 1380 Lucky number in matrix
- Sqli-labs customs clearance (less2-less5)
- Overload global and member new/delete
- [Zhang San learns C language] - deeply understand data storage
- Browser scrolling for more implementations
- sqli-labs通关汇总-page2
- In depth study of JVM bottom layer (V): class loading mechanism
猜你喜欢
Go package name
SQL injection closure judgment
Build learning tensorflow
Sentry construction and use
Sqli Labs clearance summary - page 2
In depth study of JVM bottom layer (3): garbage collector and memory allocation strategy
Spark的原理解析
Queue (linear structure)
Uniapp introduces local fonts
Self study table Au
随机推荐
Implement strstr() II
oracle-外币记账时总账余额表gl_balance变化(上)
PXC high availability cluster summary
IDEA2020中PySpark的两表关联(字段名相同)
sqli-labs通關匯總-page2
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
Atcoder beginer contest 253 F - operations on a matrix / / tree array
JS delete the last character of the string
Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix
flex九宫格布局
Oracle apex 21.2 installation and one click deployment
Tool grass welfare post
Overload global and member new/delete
UEditor . Net version arbitrary file upload vulnerability recurrence
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
js创建一个自定义json数组
SQLI-LABS通關(less6-less14)
Take you to master the formatter of visual studio code
js删除字符串的最后一个字符
Use of interrupt()