SlideShare a Scribd company logo
1 of 2
Step 2: Build a Rman Script. There are a couple of ways to recover to a point in
time and we have decided to use SCN numbers. Since this process needs to be
automated, we query productions rman catalog and determine the proper SCN to use
and build an rman script. Here it is:
set feedback off
set echo off
set serverout on
spool $HOME/scripts/prod_to_vis.sql
declare
vmax_fuzzy number;
vmax_ckp number;
scn number;
db_name varchar2(3) := 'VIS';
log_file_dest1 varchar2(30) := '/dbf/visdata/';
begin
select max(absolute_fuzzy_change#)+1,
max(checkpoint_change#)+1
into vmax_fuzzy, vmax_ckp
from rc_backup_datafile;
if vmax_fuzzy > vmax_ckp then
scn := vmax_fuzzy;
else
scn := vmax_ckp;
end if;
dbms_output.put_line('run {');
dbms_output.put_line('set until scn '||to_char(scn)||';');
dbms_output.put_line('allocate auxiliary channel ch1 type disk;');
dbms_output.put_line('allocate auxiliary channel ch2 type disk;');
dbms_output.put_line('duplicate target database to '||db_name);
dbms_output.put_line('logfile group 1 ('||chr(39)||
log_file_dest1||'log01a.dbf'||chr(39)||',');
dbms_output.put_line(chr(39)||log_file_dest1||'log01b.dbf'||chr(39)||') size
10m,');
dbms_output.put_line('group 2 ('||chr(39)||log_file_dest1||'log02a.dbf'||
chr(39)||',');
dbms_output.put_line(chr(39)||log_file_dest1||'log02b.dbf'||chr(39)||') size
10m;}');
dbms_output.put_line('exit;');
end;
/
spool off;
This script produces a spool file called, prod_to_vis.sql:
run {
set until scn 14085390202;
allocate auxiliary channel ch1 type disk;
allocate auxiliary channel ch2 type disk;
duplicate target database to VIS
logfile group 1 ('/dbf/visdata/log01a.dbf',
'/dbf/visdata/log01b.dbf') size 10m,
group 2 ('/oradata/dbf/visdata/log02a.dbf',
'/dbf/visdata/log02b.dbf') size 10m;}
exit;
Note: Our production nightly backups are on disk which are NFS mounted to our
test server.
Step 3: Execute the rman script. Launch rman, connect to the target, catalog,
auxiliary and execute the script above:
ie.
rman> connect target sys/syspasswd@PROD catalog rmancat/catpasswd@REPO auxiliary
/
You may want to put some error checking around rman to alert you if it fails. We
have a wrapper script which supplies the connection information and calls the
rman script above. Our refresh is critical so if it fails we need to be paged.
rman @$SCRIPTS/prod_to_vis.sql
if [ $? != 0 ]
then
echo Failed
echo "RMAN Dupcliate Failed!"|mailx -s "Test refresh failed"
pageremail@mycompany.com
exit 1
fi
Step 4: If production is in archivelog mode but test isn't, then mount the
database and alter database noarchivelog;

More Related Content

Similar to Rman script build_space_issue

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
tomcopeland
 
Trouble shooting apachecloudstack
Trouble shooting apachecloudstackTrouble shooting apachecloudstack
Trouble shooting apachecloudstack
Sailaja Sunil
 
Create guaranteed restore point
Create guaranteed restore pointCreate guaranteed restore point
Create guaranteed restore point
Viaggio Italia
 

Similar to Rman script build_space_issue (20)

Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
Experience on porting HIGHMEM and KASAN to RISC-V at COSCUP 2020
 
sas aeroplan sample
sas aeroplan samplesas aeroplan sample
sas aeroplan sample
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
Trouble shooting apachecloudstack
Trouble shooting apachecloudstackTrouble shooting apachecloudstack
Trouble shooting apachecloudstack
 
WMQ Toolbox: 20 Scripts, One-liners, & Utilities for UNIX & Windows
WMQ Toolbox: 20 Scripts, One-liners, & Utilities for UNIX & Windows WMQ Toolbox: 20 Scripts, One-liners, & Utilities for UNIX & Windows
WMQ Toolbox: 20 Scripts, One-liners, & Utilities for UNIX & Windows
 
Nagios Conference 2013 - Troy Lea - Leveraging and Understanding Performance ...
Nagios Conference 2013 - Troy Lea - Leveraging and Understanding Performance ...Nagios Conference 2013 - Troy Lea - Leveraging and Understanding Performance ...
Nagios Conference 2013 - Troy Lea - Leveraging and Understanding Performance ...
 
Operating CloudStack: Sharing My Tool Box @ApacheCon NA'15
Operating CloudStack: Sharing My Tool Box @ApacheCon NA'15Operating CloudStack: Sharing My Tool Box @ApacheCon NA'15
Operating CloudStack: Sharing My Tool Box @ApacheCon NA'15
 
Adding Statistical Functionality to the DATA Step with PROC FCMP
Adding Statistical Functionality to the DATA Step with PROC FCMPAdding Statistical Functionality to the DATA Step with PROC FCMP
Adding Statistical Functionality to the DATA Step with PROC FCMP
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
Create guaranteed restore point
Create guaranteed restore pointCreate guaranteed restore point
Create guaranteed restore point
 
PROTTPLV.PPT computer programme statement
PROTTPLV.PPT computer programme statementPROTTPLV.PPT computer programme statement
PROTTPLV.PPT computer programme statement
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Using script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and ExcelUsing script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and Excel
 
Checking Oracle VM VirtualBox. Part 1
Checking Oracle VM VirtualBox. Part 1Checking Oracle VM VirtualBox. Part 1
Checking Oracle VM VirtualBox. Part 1
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
MySQL Galera 集群
MySQL Galera 集群MySQL Galera 集群
MySQL Galera 集群
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
 

More from Nabi Abdul (6)

Rman workshop short
Rman workshop shortRman workshop short
Rman workshop short
 
Rman 12c new_features
Rman 12c new_featuresRman 12c new_features
Rman 12c new_features
 
Rman backup and recovery 11g new features
Rman backup and recovery 11g new featuresRman backup and recovery 11g new features
Rman backup and recovery 11g new features
 
Rman 11g new features
Rman 11g new featuresRman 11g new features
Rman 11g new features
 
Oracle 11g nf_1.0
Oracle 11g nf_1.0Oracle 11g nf_1.0
Oracle 11g nf_1.0
 
Duplicate database advanced method for distributing datafiles into multiple l...
Duplicate database advanced method for distributing datafiles into multiple l...Duplicate database advanced method for distributing datafiles into multiple l...
Duplicate database advanced method for distributing datafiles into multiple l...
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Rman script build_space_issue

  • 1. Step 2: Build a Rman Script. There are a couple of ways to recover to a point in time and we have decided to use SCN numbers. Since this process needs to be automated, we query productions rman catalog and determine the proper SCN to use and build an rman script. Here it is: set feedback off set echo off set serverout on spool $HOME/scripts/prod_to_vis.sql declare vmax_fuzzy number; vmax_ckp number; scn number; db_name varchar2(3) := 'VIS'; log_file_dest1 varchar2(30) := '/dbf/visdata/'; begin select max(absolute_fuzzy_change#)+1, max(checkpoint_change#)+1 into vmax_fuzzy, vmax_ckp from rc_backup_datafile; if vmax_fuzzy > vmax_ckp then scn := vmax_fuzzy; else scn := vmax_ckp; end if; dbms_output.put_line('run {'); dbms_output.put_line('set until scn '||to_char(scn)||';'); dbms_output.put_line('allocate auxiliary channel ch1 type disk;'); dbms_output.put_line('allocate auxiliary channel ch2 type disk;'); dbms_output.put_line('duplicate target database to '||db_name); dbms_output.put_line('logfile group 1 ('||chr(39)|| log_file_dest1||'log01a.dbf'||chr(39)||','); dbms_output.put_line(chr(39)||log_file_dest1||'log01b.dbf'||chr(39)||') size 10m,'); dbms_output.put_line('group 2 ('||chr(39)||log_file_dest1||'log02a.dbf'|| chr(39)||','); dbms_output.put_line(chr(39)||log_file_dest1||'log02b.dbf'||chr(39)||') size 10m;}'); dbms_output.put_line('exit;'); end; / spool off; This script produces a spool file called, prod_to_vis.sql: run { set until scn 14085390202; allocate auxiliary channel ch1 type disk; allocate auxiliary channel ch2 type disk; duplicate target database to VIS logfile group 1 ('/dbf/visdata/log01a.dbf', '/dbf/visdata/log01b.dbf') size 10m, group 2 ('/oradata/dbf/visdata/log02a.dbf', '/dbf/visdata/log02b.dbf') size 10m;} exit; Note: Our production nightly backups are on disk which are NFS mounted to our test server. Step 3: Execute the rman script. Launch rman, connect to the target, catalog, auxiliary and execute the script above: ie. rman> connect target sys/syspasswd@PROD catalog rmancat/catpasswd@REPO auxiliary /
  • 2. You may want to put some error checking around rman to alert you if it fails. We have a wrapper script which supplies the connection information and calls the rman script above. Our refresh is critical so if it fails we need to be paged. rman @$SCRIPTS/prod_to_vis.sql if [ $? != 0 ] then echo Failed echo "RMAN Dupcliate Failed!"|mailx -s "Test refresh failed" pageremail@mycompany.com exit 1 fi Step 4: If production is in archivelog mode but test isn't, then mount the database and alter database noarchivelog;