当前位置:网站首页>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 .
边栏推荐
- js的防抖和节流
- Oracle rman自动恢复脚本(生产数据向测试迁移)
- sqli-labs通关汇总-page1
- 2021-07-05c /cad secondary development create arc (4)
- SQL注入闭合判断
- Latex warning: citation "*****" on page y undefined on input line*
- ARP攻击
- How to debug wechat built-in browser applications (enterprise number, official account, subscription number)
- CAD secondary development object
- CSRF攻击
猜你喜欢

Huawei mindspire open source internship machine test questions

Sqli Labs clearance summary - page 2

SQLI-LABS通关(less2-less5)

Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix

Sqli-labs customs clearance (less18-less20)

Flex Jiugongge layout

mapreduce概念和案例(尚硅谷学习笔记)

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

Network security -- intrusion detection of emergency response

PgSQL learning notes
随机推荐
Oracle APEX 21.2 installation et déploiement en une seule touche
MySQL index
php中判断版本号是否连续
Oracle rman自动恢复脚本(生产数据向测试迁移)
Win10: add or delete boot items, and add user-defined boot files to boot items
Oracle段顾问、怎么处理行链接行迁移、降低高水位
js把一个数组分割成每三个一组
php中的二维数组去重
Sentry construction and use
js的防抖和节流
Date time API details
sqli-labs通关汇总-page2
IDEA2020中PySpark的两表关联(字段名相同)
UEditor .Net版本任意文件上传漏洞复现
PHP Session原理简析
Code execution sequence with and without resolve in promise
Log - 7 - record a major error in missing documents (A4 paper)
JS divides an array into groups of three
Latex warning: citation "*****" on page y undefined on input line*
Sqli-labs customs clearance (less2-less5)