Skip to content

Oracle method of restoring a database using a disk-based rman backup - scripts auto-generated before an upgrade

When upgrading to 12.2.0.1, you can opt to create a restorable backup in case things go wrong. These are the scripts that are created.

Driving shell script (upg_restore.sh)

These scripts are auto-generated by dbua. Instance name being upgraded is upg!

#!/bin/sh

# -- Run this Script to Restore Oracle Database Instance upg
echo -- Bringing up the database from the source oracle home
ORACLE_HOME=/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1; export ORACLE_HOME
ORACLE_SID=upg; export ORACLE_SID
/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1/bin/sqlplus /nolog @/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/shutdown_upg.sql
echo -- Bringing down the database from the new oracle home
ORACLE_HOME=/cln/tst/ora_bin1/app/oracle/product/12.2.0.1/dbhome_1; export ORACLE_HOME
ORACLE_SID=upg; export ORACLE_SID
/cln/tst/ora_bin1/app/oracle/product/12.2.0.1/dbhome_1/bin/sqlplus /nolog @/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/shutdown_upg.sql
echo -- Removing database instance from new oracle home ...
echo You should Remove this entry from the /etc/oratab: upg:/cln/tst/ora_bin1/app/oracle/product/12.2.0.1/dbhome_1:N
echo -- Bringing up the database from the source oracle home
ORACLE_HOME=/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1; export ORACLE_HOME
ORACLE_SID=upg; export ORACLE_SID
unset LD_LIBRARY_PATH; unset LD_LIBRARY_PATH_64; unset SHLIB_PATH; unset LIB_PATH
echo You should Add this entry in the /etc/oratab: upg:/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1:Y
cd /cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1
echo -- Removing /cln/tst/ora_bin1/app/oracle/cfgtoollogs/dbua/logs/Welcome_upg.txt file
rm -f /cln/tst/ora_bin1/app/oracle/cfgtoollogs/dbua/logs/Welcome_upg.txt ;
/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1/bin/sqlplus /nolog @/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/createSPFile_upg.sql
/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1/bin/rman  @/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/rmanRestoreCommands_upg
echo -- Execution of restore script for the database UPG completed.

shutdown_upg.sql

connect / as sysdba
shutdown abort;
exit;

createSPFile_upg.sql

connect / as sysdba
startup nomount pfile='/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/init.ora';
CREATE SPFILE='/cln/tst/ora_bin1/app/oracle/product/12.1.0.2/dbhome_1/dbs/spfileupg.ora' from pfile='/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/init.ora';
shutdown immediate;
exit;

rmanRestoreCommands_upg

connect target /;
startup force  nomount;
set nocfau;
restore controlfile from '/cln/tst/ora_bin1/app/oracle/admin/upg/backup_2019-03-01_01-58-37-PM/ctl_backup_1551448396460';
startup force  mount;
restore database;
alter database open resetlogs;
exit

startup_upg.sql

connect / as sysdba
startup;
exit;

init.ora

upg.__data_transfer_cache_size=0
upg.__db_cache_size=855638016
upg.__java_pool_size=16777216
upg.__large_pool_size=603979776
upg.__oracle_base='/cln/tst/ora_bin1/app/oracle'#ORACLE_BASE set from environment
upg.__pga_aggregate_target=637534208
upg.__sga_target=2097152000
upg.__shared_io_pool_size=83886080
upg.__shared_pool_size=520093696
upg.__streams_pool_size=0
*.audit_file_dest='/cln/tst/ora_bin1/app/oracle/admin/upg/adump'
*.audit_sys_operations=TRUE
*.audit_syslog_level='local0.info'
*.audit_trail='OS'
*.compatible='12.1.0.2.0'
*.control_file_record_keep_time=28
*.control_files='/cln/tst/ora_data3/upg/control02.ctl','/cln/tst/ora_data3/upg/control03.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_domain='world'
*.db_file_name_convert='/cln/tst/ora_data3/monprodt','/cln/tst/ora_data3/upg'
*.db_name='UPG'#Reset to original value by RMAN
*.diagnostic_dest='/cln/tst/ora_bin1/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=monprodtXDB)'
*.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=hn481)(PORT=3529))'
*.log_archive_dest_1='Location=/cln/tst/ora_data1/archivelog/upg/'
*.log_archive_format='log%t_%s_%r.arc'
*.log_file_name_convert='/cln/tst/ora_data3/monprodt','/cln/tst/ora_data3/upg'
*.memory_max_target=0
*.memory_target=0
*.open_cursors=300
*.pga_aggregate_target=629145600
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2097152000
*.undo_tablespace='UNDOTBS1'