You are on page 1of 2

# NAME

# Arch_Extract.rcv
#
# DESCRIPTION
# This script may be used to extract the Archive log files from the backup
piece.
#
# CREATED
# 05/23/04 - Mark Mendonca
#
# MODIFIED (MM/DD/YY)

run{
allocate clone channel c1 type disk;
allocate clone channel c2 type disk;
set newname for datafile 17
to '/recover/scratch/RMAN1A/CLONE1A/oradata/si2_RMAN1A_01.dbf';
recover tablespace users
until time "to_date('March-26-2004:15:20:00','Month-DD-YYYY:HH24:MI:SS')";}

Though it is more likely that you will use TSPITR to recover to a date and time,
you can use the syntax below to recover to a specific log sequence number.

run{
allocate clone channel c1 type disk;
allocate clone channel c2 type disk;
set newname for datafile 17
to '/recover/scratch/RMAN1A/CLONE1A/oradata/si2_RMAN1A_01.dbf';
recover tablespace SI1
until logseq 13 thread 1;}

DECLARE
v_dev varchar2(50); -- device type allocated for restore
v_done boolean:=false; -- has the log been fully extracted yet
type t_fileTable is table of varchar2(255) index by binary_integer;
v_fileTable t_fileTable; -- Stores the backuppiece names
v_maxPieces number:=1; -- Number of backuppieces in backupset

BEGIN

-- Initialise the filetable & number of backup pieces in the backupset


-- This section of code MUST be edited to reflect the customer's
-- available backupset before the procedure is compiled and run.
-- In this example, the archivelog backupset consists of 2 pieces:

v_fileTable(1):='al_s20_p1';
v_fileTable(2):='al_s20_p2';
v_maxPieces:=2;

-- Allocate a device. In this example, I have specified 'sbt_tape' as I -- am


reading backuppieces from the media manager.
-- If the backuppiece is on disk, specify type=>null

v_dev:=sys.dbms_backup_restore.deviceAllocate(type=>'sbt_tape',
ident=>'t1');

-- Begin the restore conversation

sys.dbms_backup_restore.restoreSetArchivedLog(destination=>'/support2/OFA_V804/app/
oracle/admin/arch/arch_');

-- Specify where the archivelog is to be recreated

sys.dbms_backup_restore.restoreArchivedLog(thread=>1,
sequence=>100);

-- Restore the archivelog

FOR i IN 1..v_maxPieces LOOP


sys.dbms_backup_restore.restoreBackupPiece(done=>v_done,
handle=>v_fileTable(i),
params=>null);
IF v_done THEN
GOTO all_done;
END IF;
END LOOP;

<<all_done>>
-- Deallocate the device
sys.dbms_backup_restore.deviceDeallocate;

END;
/

For restoring multiple archives from a backupset, add a loop


around sys.dbms_backup_restore.restoreArchivedLog()

for seq in <min seq#>..<max seq#> loop


sys.dbms_backup_restore.restoreArchivedLog(thread=>1,
sequence=>seq);
end loop

You might also like