转Metalink]
How to extract controlfiles, datafiles, and archived logs from SMR backupsets without using RMAN
R6B x ?,i!K0
|
|
How to extract controlfiles, datafiles, and archived logs from
SMR backupsets without using RMAN
Introduction:
When using RMAN to restore objects (datafiles, controlfiles, or archivelogs)
from backupsets, the object restore can be driven from the recovery catalog
or the target database controlfile. This note explains how to extract
objects from backupsets when the recovery catalog and controlfiles have been
lost. In this scenario, you effectively perform. the RMAN functions through
PL/SQL procedure calls
Contents:
1. Prerequisites
2. Extracting the controlfile from a backupset
3. Extracting datafiles from a backupset
4. Applying incrementals
5. Extracting archivelogs from a backupset
6. A typical scenario
7. Errors
8. Things to be done
1. Prerequisites
The customer must have a knowledge of the contents of backupsets i.e. what
they contain, when the backups were created, and the type of backups. Ideally
they should have logs of the RMAN backup sessions that produced the
backupsets.
Note that the following anonymous PL/SQL blocks are run on the instance of
the database being recovered (the 'target'). The instance must be at least
started (once the controlfile has been restored the database can also be
mounted). Anonymous blocks can be executed in this manner as long as they
call only 'fixed' packages. The DBMS_BACKUP_RESTORE packages are fixed.
IMPORTANT: All the anonymous blocks must be executed by SYS or a user
who has execute privilege on SYS.DBMS_BACKUP_RESTORE
2. Extracting the controlfile from a backupset
The first stage is to extract the controlfile from a backupset. This is
achieved by making use of the following SYS.DBMS_BACKUP_RESTORE packaged
functions & procedures:
FUNCTION deviceAllocate - allocates a device for sequential I/O
PROCEDURE restoreSetDataFile - begins a restore conversation
PROCEDURE restoreControlfileTo - specifies the controlfile destination
PROCEDURE restoreBackupPiece - performs the restore
PROCEDURE deviceDeallocate - deallocates the I/O device
The following anonymous block can be created and executed to restore a
controlfile from a backupset. Before executing it, you MUST edit the block
as follows:
a. The filetable PL/SQL table entries must reflect the backuppieces
comprising the backupset
b. The v_maxPieces variable must reflect the number of backuppieces
comprising the backupset
c. The call to restoreControlfileTo must specify the correct controlfile
path & filename
IMPORTANT: The latest backup of the controlfile should be restored. Because
recovery (using backup controlfile) will be performed manually,
the recovering session will need to start applying redo from
the current log sequence AT THE TIME OF THE CONTROLFILE BACKUP.
Thus, to take advantage of incremental backups, restore a
controlfile taken along with the incremental backups, thus
reducing the amount of redo required during recovery.
DECLARE
v_dev varchar2(50); -- device type allocated for restore
v_done boolean; -- has the controlfile 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
-- backupset consists of 4 pieces:
v_fileTable(1):='fulldb_s15_p1';
v_fileTable(2):='fulldb_s15_p2';
v_fileTable(3):='fulldb_s15_p3';
v_fileTable(4):='fulldb_s15_p4';
v_maxPieces:=4;
-- 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.restoreSetDatafile;
-- Specify where the controlfile is to be recreated
sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/support2/OFA_V804/u1/oradata/dbs/ctrl1V804.ctl');
-- Restore the controlfile
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;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22036495/viewspace-1024440/ ,如需转载,请注明出处,否则将追究法律责任。