Create The World With Creativity
 
Welcome, Guest:Log in | Register | Information Center | Languages | Search | Tags | FAQs | Lite
There was a problem with the request. Check your permission or contact with administrator.




Your Ad Here

Grade this thread

Quote Favorites Report
Starter:  Topic: : Restore database without controlfiles/RMAN
R.Wang 
5 Stars
 

Info: Moderator Offline Male
From: Not Specified 
Posts: 329  
Digest 0  
Credits: 59
Money: 1746 $OraclePoint
Registered on 2007-04-20
ProfileProfile BuddyBuddy PMPM Reply Reply QuotesQuotes   1 F 
Restore database without controlfiles/RMAN



How to extract controlfiles, datafiles, and archived logs from SMR backupsets without using RMAN  
[url=http://www.oraclepoint.com]swZEtqwc1OraclePointzCPLP9xCA[/url]


Keyword: DBMS_BACKUP_RESTORE
[url=http://www.oraclepoint.com]HbhQxPGlsOraclePointTxVZfHzj2[/url]

Introduction:

  When using RMAN to restore objects (datafiles, controlfiles, or archivelogs)
[url=http://www.oraclepoint.com]gWUWMWlXmOraclePointkKplRHIi5[/url]

  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
[url=http://www.oraclepoint.com]YogH9TcYzOraclePointkNZctvwG9[/url]

  lost. In this scenario, you effectively perform the RMAN functions through
  PL/SQL procedure calls
[url=http://www.oraclepoint.com]JsVwSgc4xOraclePointjBVeaAAh0[/url]


Contents:
[url=http://www.oraclepoint.com]TAXIlliDVOraclePointT1bRAKnxc[/url]

  1. Prerequisites
  2. Extracting the controlfile from a backupset
  3. Extracting datafiles from a backupset
[url=http://www.oraclepoint.com]JPW8yYTSyOraclePointUSWTmWrv8[/url]

  4. Applying incrementals
  5. Extracting archivelogs from a backupset
  6. A typical scenario  
[url=http://www.oraclepoint.com]TTBon2G53OraclePointQiptr5Fot[/url]

  7. Errors
  8. Things to be done
[url=http://www.oraclepoint.com]d8CRRUnl8OraclePointATs9mC0Rp[/url]


1. Prerequisites
[url=http://www.oraclepoint.com]2XktoIZX1OraclePointTcfD6cFNu[/url]

  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  
[url=http://www.oraclepoint.com]a2WX2qG1SOraclePointJ1jys8Zbl[/url]

  backupsets.

  Note that the following anonymous PL/SQL blocks are run on the instance of
[url=http://www.oraclepoint.com]i29YLb4OXOraclePointWTkHuceHU[/url]

  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
[url=http://www.oraclepoint.com]KOKdXADMsOraclePointAmKmKCljN[/url]

  call only 'fixed' packages. The DBMS_BACKUP_RESTORE packages are fixed.

  IMPORTANT: All the anonymous blocks must be executed by SYS or a user
[url=http://www.oraclepoint.com]CdbZ1vA8fOraclePointccnxm38FP[/url]

             who has execute privilege on SYS.DBMS_BACKUP_RESTORE

[url=http://www.oraclepoint.com]9IcrJE3vPOraclePoint5WyHZRjzH[/url]

2. Extracting the controlfile from a backupset


  The first stage is to extract the controlfile from a backupset. This is  
[url=http://www.oraclepoint.com]VzF2SheFKOraclePointXDQnCZFti[/url]

  achieved by making use of the following SYS.DBMS_BACKUP_RESTORE packaged
  functions & procedures:
[url=http://www.oraclepoint.com]KmUZhqNpGOraclePointfO6mkvsbE[/url]

    FUNCTION deviceAllocate                - allocates a device for sequential I/O
    PROCEDURE restoreSetDataFile        - begins a restore conversation
    PROCEDURE restoreControlfileTo        - specifies the controlfile destination
[url=http://www.oraclepoint.com]P7JaTNq7POraclePointFC0oMm9lJ[/url]

    PROCEDURE restoreBackupPiece         - performs the restore
    PROCEDURE deviceDeallocate                - deallocates the I/O device
[url=http://www.oraclepoint.com]pzyvUDq8nOraclePointcpFg6CqVV[/url]

  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:
[url=http://www.oraclepoint.com]4CSJHVJvhOraclePointwuJ6Z0uKT[/url]


    a. The filetable PL/SQL table entries must reflect the backuppieces
       comprising the backupset
[url=http://www.oraclepoint.com]y2RcT8h14OraclePointkgP7aROkZ[/url]

    b. The v_maxPieces variable must reflect the number of backuppieces
       comprising the backupset
    c. The call to restoreControlfileTo must specify the correct controlfile
[url=http://www.oraclepoint.com]jtLHg6RbUOraclePointQMfkBX3dr[/url]

       path & filename

  IMPORTANT: The latest backup of the controlfile should be restored. Because
[url=http://www.oraclepoint.com]zBhslE8heOraclePointOwEoWyzeU[/url]

             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.
[url=http://www.oraclepoint.com]uvwFC9lm0OraclePoint0edqUeOCG[/url]

             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.
[url=http://www.oraclepoint.com]SAnwPa24wOraclePointptQ0dCvjE[/url]

________________________________________________________________________________
    
    DECLARE
[url=http://www.oraclepoint.com]uLruKMN2gOraclePointsFjyYjcLz[/url]

      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)
[url=http://www.oraclepoint.com]3Ctprc7r6OraclePoint0cfDMqv72[/url]

      index by binary_integer;
      v_fileTable     t_fileTable;    -- Stores the backuppiece names
      v_maxPieces     number:=1;    -- Number of backuppieces in backupset
[url=http://www.oraclepoint.com]8Kte3yDqNOraclePointnIZcBbLrJ[/url]

      
    BEGIN
    
[url=http://www.oraclepoint.com]on1kmTFqgOraclePointwbdoZnX4f[/url]

    -- Initialise the filetable & number of backup pieces in the backupset
    -- This section of code MUST be edited to reflect the customers available
    -- backupset before the procedure is compiled and run. In this example, the
[url=http://www.oraclepoint.com]M7LZkUyCWOraclePointQODa3rQcU[/url]

    -- backupset consists of 4 pieces:
 
      v_fileTable(1):='fulldb_s15_p1';
[url=http://www.oraclepoint.com]kiAGVcj02OraclePointMWusjq40Q[/url]


      v_fileTable(2):='fulldb_s15_p2';
[url=http://www.oraclepoint.com]OxTlEioebOraclePointWv5qVdqcy[/url]

      v_fileTable(3):='fulldb_s15_p3';

      v_fileTable(4):='fulldb_s15_p4';
[url=http://www.oraclepoint.com]IByAOLu7uOraclePointb1tsFhCql[/url]


      v_maxPieces:=4;
[url=http://www.oraclepoint.com]lVGCr28XNOraclePointbEpPMrEN6[/url]

    -- 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
[url=http://www.oraclepoint.com]P820YrsHwOraclePointPJd2uy8xf[/url]


      v_dev:=sys.dbms_backup_restore.deviceAllocate(type=>'sbt_tape',ident=>'t1');
[url=http://www.oraclepoint.com]zv3CM8sbKOraclePointZgXVvUMut[/url]

    -- Begin the restore conversation

      sys.dbms_backup_restore.restoreSetDatafile;
[url=http://www.oraclepoint.com]5d1rtAKkuOraclePoint0iieXTXaf[/url]


    -- Specify where the controlfile is to be recreated
[url=http://www.oraclepoint.com]UJ8eid24POraclePointMG06BcwtL[/url]

      sys.dbms_backup_restore.restoreControlfileTo(cfname=>'/support2/OFA_V804/u1/oradata/dbs/ctrl1V804.ctl');

    -- Restore the controlfile
[url=http://www.oraclepoint.com]w4wh4VGXtOraclePointZvJ6GT4l2[/url]


      FOR i IN 1..v_maxPieces LOOP
[url=http://www.oraclepoint.com]Xdvmp3ml4OraclePointEYmQLgDsZ[/url]

        sys.dbms_backup_restore.restoreBackupPiece(done=>v_done,handle=>v_fileTable(i),params=>null);

        IF v_done THEN
[url=http://www.oraclepoint.com]YzxHPjRKqOraclePointkERcbuOEa[/url]

          GOTO all_done;
        END IF;
[url=http://www.oraclepoint.com]GqBAvamClOraclePointJFUjeJXmY[/url]

      END LOOP;

    <<all_done>>
[url=http://www.oraclepoint.com]74jnen57FOraclePointpKKFR1HRl[/url]


        -- Deallocate the device
[url=http://www.oraclepoint.com]h5nJDtdmNOraclePointmAzB8tkkN[/url]

      sys.dbms_backup_restore.deviceDeallocate;

    END;
[url=http://www.oraclepoint.com]OeKUKVePmOraclePointUX576ykE2[/url]


    /

_______________________________________________________________________________________
[url=http://www.oraclepoint.com]ThehKeXLbOraclePointHwBVAggVq[/url]


3. Extracting datafiles from a backupset
[url=http://www.oraclepoint.com]2z7eKTYHPOraclePointMrTEB2jjB[/url]

  The second stage is to extract the datafiles from a backupset. This is
  achieved by making use of the following SYS.DBMS_BACKUP_RESTORE packaged
  functions & procedures:
[url=http://www.oraclepoint.com]D8NfE0haAOraclePointD7VuyLqSV[/url]


    FUNCTION deviceAllocate             - allocates a device for sequential I/O
    PROCEDURE restoreSetDataFile        - begins a restore conversation
[url=http://www.oraclepoint.com]ArcP5Kj0LOraclePointaiuclrpHw[/url]

    PROCEDURE restoreDataFileTo              - datafile number & destination
    PROCEDURE restoreBackupPiece        - performs the restore
    PROCEDURE deviceDeallocate          - deallocates the I/O device
[url=http://www.oraclepoint.com]ooMprIAb7OraclePointLIPhJ80Y2[/url]


  The following anonymous block can be created and executed to restore a
  datafile from a backupset. Before executing it, you MUST edit the block
[url=http://www.oraclepoint.com]K92VYZG1BOraclePointygIkLwx1e[/url]

  as follows:  

    a. The filetable PL/SQL table entries must reflect the backuppieces
[url=http://www.oraclepoint.com]7274DEIkNOraclePointGkm9ukzG0[/url]

       comprising the backupset
    b. The v_maxPieces variable must reflect the number of backuppieces
       comprising the backupset
[url=http://www.oraclepoint.com]OM1PBWXlhOraclePointKZXoVPkOS[/url]

    c. The call to restoreDataFileTo must specify the correct datafile number,
       and datafile path & filename
[url=http://www.oraclepoint.com]pX44ddgcOOraclePointGRUGgh7vi[/url]

_______________________________________________________________________________

    DECLARE
[url=http://www.oraclepoint.com]TJK1UjO96OraclePointdjKwOhpHB[/url]


      v_dev        varchar2(50);        -- device type allocated for restore
[url=http://www.oraclepoint.com]JodYuvt2ROraclePointQyDzHM08h[/url]

      v_done    boolean:=false; -- has the datafile been fully extracted yet

      type t_fileTable is table of varchar2(255)
[url=http://www.oraclepoint.com]jMffqFpdTOraclePointMIbOSFsq1[/url]


      index by binary_integer;
[url=http://www.oraclepoint.com]dZsuqgyfnOraclePointBfliFyDke[/url]

      v_fileTable     t_fileTable;        -- Stores the backuppiece names

      v_maxPieces     number:=1;        -- Number of backuppieces in backupset
[url=http://www.oraclepoint.com]IP8ccG5rYOraclePoint0ZE13einK[/url]


    BEGIN
[url=http://www.oraclepoint.com]EbpscLTBQOraclePointHE2mNGjqj[/url]

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

    -- This section of code MUST be edited to reflect the customers available
[url=http://www.oraclepoint.com]qkQEkpJbiOraclePointn0MyEoewH[/url]


    -- backupset before the procedure is compiled and run. In this example, the
[url=http://www.oraclepoint.com]pFI7NNxzbOraclePoint5ZHdFstKT[/url]

    -- backupset consists of 4 pieces:

      v_fileTable(1):='fulldb_s15_p1';
[url=http://www.oraclepoint.com]ZTu98tKwyOraclePointyQk77qE34[/url]


      v_fileTable(2):='fulldb_s15_p2';
[url=http://www.oraclepoint.com]RqttkI2DNOraclePointjxX3MrmLp[/url]

      v_fileTable(3):='fulldb_s15_p3';

      v_fileTable(4):='fulldb_s15_p4';
[url=http://www.oraclepoint.com]WVbKKrvGoOraclePointbLgUdMDMw[/url]


      v_maxPieces:=4;
[url=http://www.oraclepoint.com]MD1anoyf2OraclePointfICLfXmpi[/url]

    -- 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,
[url=http://www.oraclepoint.com]Uap931fMUOraclePointrQhedkV4O[/url]


    -- specify type=>null
[url=http://www.oraclepoint.com]0ru1N33YXOraclePointQADzVeeTW[/url]

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

    -- Begin the restore conversation
[url=http://www.oraclepoint.com]Vzjph1NBTOraclePointyXNCX5wNH[/url]


      sys.dbms_backup_restore.restoreSetDatafile;
[url=http://www.oraclepoint.com]pGfCWgGL2OraclePointlqL8BAhrh[/url]

    -- Specify where the datafile is to be recreated

      sys.dbms_backup_restore.restoreDataFileTo(dfnumber=>1,toname=>'/support2/OFA_V804/u1/oradata/dbs/sysV804.dbf');
[url=http://www.oraclepoint.com]Y5jss86vUOraclePointzhi7MocPB[/url]


    -- Restore the datafile
[url=http://www.oraclepoint.com]9WN184B66OraclePointCcnk2hKjQ[/url]

      FOR i IN 1..v_maxPieces LOOP

        sys.dbms_backup_restore.restoreBackupPiece(done=>v_done,handle=>v_fileTable(i),params=>null);
[url=http://www.oraclepoint.com]HeCcTjAQwOraclePointosCpqY4hV[/url]


        IF v_done THEN
          GOTO all_done;
[url=http://www.oraclepoint.com]wjQsmtVMkOraclePoint4XJJfnM88[/url]

        END IF;

      END LOOP;
[url=http://www.oraclepoint.com]v8Nim6kSmOraclePoint9LKU9tlqV[/url]


      <<all_done>>
[url=http://www.oraclepoint.com]UBi656FEaOraclePointtQYqCV5k9[/url]

    -- Deallocate the device

      sys.dbms_backup_restore.deviceDeallocate;
[url=http://www.oraclepoint.com]1LQcJcndaOraclePointWFHraIPVD[/url]


    END;
[url=http://www.oraclepoint.com]LbHlKY02aOraclePointVvBUlMlEV[/url]

    /

_______________________________________________________________________________________
[url=http://www.oraclepoint.com]DrzeE5lwVOraclePointuCqxNH6zS[/url]

4. Applying incrementals

  If incrementals are to be applied, you must execute this anonymous block
[url=http://www.oraclepoint.com]TzJtK5ufgOraclePoint8GlSJSIoW[/url]

  for each incremental datafile backup. The following SYS.DBMS_BACKUP_RESTORE
  packaged functions & procedures are called:
[url=http://www.oraclepoint.com]DQJYALFyYOraclePointNtNfDCpwN[/url]

    FUNCTION deviceAllocate             - allocates a device for sequential I/O
    PROCEDURE applySetDataFile          - begins a restore conversation
    PROCEDURE applyDataFileTo           - datafile number & destination
[url=http://www.oraclepoint.com]khsGeyrx9OraclePointA7mXA3gZ4[/url]

    PROCEDURE applyBackupPiece          - performs the restore
    PROCEDURE deviceDeallocate          - deallocates the I/O device
[url=http://www.oraclepoint.com]rerGsbTNeOraclePointW3RkczSjU[/url]

  The following anonymous block can be created and executed to restore a
  datafile from a backupset. Before executing it, you MUST edit the block
  as follows:
[url=http://www.oraclepoint.com]HRIFRFspFOraclePointkMee40MAr[/url]


    a. The filetable PL/SQL table entries must reflect the backuppieces
       comprising the backupset
[url=http://www.oraclepoint.com]nT6IqxZQQOraclePointPi1jqHrvZ[/url]

    b. The v_maxPieces variable must reflect the number of backuppieces
       comprising the backupset
    c. The call to applyDataFileTo must specify the correct datafile number,
[url=http://www.oraclepoint.com]xeF3FRXjLOraclePointWvLEZe0hL[/url]

       and datafile path & filename

____________________________________________________________________________________
[url=http://www.oraclepoint.com]x7bEMA5vqOraclePointCdccQ7hJB[/url]


    DECLARE
[url=http://www.oraclepoint.com]ygk04WL9vOraclePointp8S2vPS1b[/url]

      v_dev           varchar2(50);           -- device type allocated for restore

      v_done          boolean:=false;  -- has the datafile been fully extracted yet
[url=http://www.oraclepoint.com]SuM0xqbP8OraclePointXwGYln0lg[/url]


      type t_fileTable is table of varchar2(255)
[url=http://www.oraclepoint.com]VwfGccYTOOraclePointnlEF5zS4m[/url]

      index by binary_integer;

      v_fileTable     t_fileTable;            -- Stores the backuppiece name
[url=http://www.oraclepoint.com]9U36spCGROraclePointpG3MborhH[/url]


      v_maxPieces     number:=1;              -- Number of backuppieces in backupset
[url=http://www.oraclepoint.com]K7aYkCdp7OraclePointS8167Ly34[/url]

    BEGIN

    -- Initialise the filetable & number of backup pieces in the backupset
[url=http://www.oraclepoint.com]d5AukGnwhOraclePointReFZoBzDm[/url]


    -- This section sp; -- backupset before the procedure is compiled and run. In this example, the
[url=http://www.oraclepoint.com]2gSyzQovMOraclePointzjEtD0tyj[/url]

    -- backupset consists of 1 piece, a level 2 backupset:

      v_fileTable(1):='fulldb_level2_s18_p1';
[url=http://www.oraclepoint.com]zbWWt1cIeOraclePointe9iGzFYo5[/url]


      v_maxPieces:=1;
[url=http://www.oraclepoint.com]oTq2IQ63TOraclePoint6lIeaj1xT[/url]

    -- 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,
[url=http://www.oraclepoint.com]qPcLtat1POraclePointyP5t5NZvW[/url]


    -- specify type=>null
[url=http://www.oraclepoint.com]prO0mzHGQOraclePointr8DBoTdzD[/url]

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

    -- Begin the restore conversation
[url=http://www.oraclepoint.com]4j5JXJDHDOraclePointQgymMf1MI[/url]


      sys.dbms_backup_restore.applySetDataFile;
[url=http://www.oraclepoint.com]qUP7CMAD1OraclePointUgpXaPRjm[/url]

    -- Specify where the datafile is to be recreated

      sys.dbms_backup_restore.applyDataFileTo(dfnumber=>1,toname=>'/support2/OFA_V804/u1/oradata/dbs/sysV804.dbf');
[url=http://www.oraclepoint.com]ante4QTgdOraclePointyXp8DAM0C[/url]


    -- Restore the datafile
[url=http://www.oraclepoint.com]YAFPUm5rDOraclePointJ0mwaPg5J[/url]

      FOR i IN 1..v_maxPieces LOOP

        sys.dbms_backup_restore.applyBackupPiece(done=>v_done,handle=>v_fileTable(i),params=>null);
[url=http://www.oraclepoint.com]wNpQCC70GOraclePoint7LG9kGEza[/url]


        IF v_done THEN
          GOTO all_done;
[url=http://www.oraclepoint.com]ruIu5HXriOraclePointnNcxAqcQt[/url]

        END IF;

      END LOOP;
[url=http://www.oraclepoint.com]fMslJ5rHfOraclePointyMUO4EXo0[/url]


    <<all_done>>
[url=http://www.oraclepoint.com]fBqDp4gc5OraclePointN6K7aXpCg[/url]

    -- Deallocate the device

      sys.dbms_backup_restore.deviceDeallocate;
[url=http://www.oraclepoint.com]juoEi1ZxuOraclePointeLYdqaJuF[/url]


    END;
[url=http://www.oraclepoint.com]DQh8dcIZ4OraclePointgE6DoprtO[/url]

    /

__________________________________________________________________________________
[url=http://www.oraclepoint.com]iICSmNqG4OraclePointGPnLT5tQY[/url]

5. Extracting archivelogs from a backupset

  The last restore stage is to extract the archivelogs from a backupset. This is
[url=http://www.oraclepoint.com]LZyE64A9hOraclePointqqR5OZ7hC[/url]

  achieved by making use of the following SYS.DBMS_BACKUP_RESTORE packaged
  functions & procedures:
[url=http://www.oraclepoint.com]JOIDUYrgrOraclePointlQ90bXxgT[/url]

    FUNCTION deviceAllocate             - allocates a device for sequential I/O
    PROCEDURE restoreSetArchivedLog     - begins a restore conversation
    PROCEDURE restoreArchivedLog        - archivelog sequence & thread numbers
[url=http://www.oraclepoint.com]qgSOM0fHNOraclePoint6Ev9O0HRU[/url]

    PROCEDURE restoreBackupPiece        - performs the restore
    PROCEDURE deviceDeallocate          - deallocates the I/O device
[url=http://www.oraclepoint.com]f91NkGMkiOraclePointjXF4ElLSy[/url]

  The following anonymous block can be created and executed to restore  
  an archivelog from a backupset. Before executing it, you MUST edit the block
  as follows:
[url=http://www.oraclepoint.com]Ky6Yu0JsNOraclePointJzfdVeUiE[/url]


    a. The filetable PL/SQL table entries must reflect the backuppieces
       comprising the backupset
[url=http://www.oraclepoint.com]bup0UCEOHOraclePointqZaekOa09[/url]

    b. The v_maxPieces variable must reflect the number of backuppieces
       comprising the backupset
    c. The call to restoreSetArchivedLog must specify the destination
[url=http://www.oraclepoint.com]aJroSgJw2OraclePointoGathLYhf[/url]

       where the archivelog is to be restored. Ideally the destination string
       should be the same as init.ora:log_archive_dest
    d. The call to restoreArchivedLog must specify the log sequence number
[url=http://www.oraclepoint.com]bltiSJ9xuOraclePointNNuMo54SM[/url]

       and thread number of the archivelog

___________________________________________________________________________________
[url=http://www.oraclepoint.com]ac9RGEszmOraclePoint4OJZpvJOD[/url]


    DECLARE
[url=http://www.oraclepoint.com]SN1DaExnsOraclePointrhB58d4Pk[/url]

      v_dev      varchar2(50);    -- device type allocated for restore

      v_done     boolean:=false; -- has the log been fully extracted yet
[url=http://www.oraclepoint.com]98ak1otQUOraclePointeZiisvZvM[/url]


      type t_fileTable is table of varchar2(255)
[url=http://www.oraclepoint.com]djzMRXOMUOraclePointrGjSEhspY[/url]

      index by binary_integer;

      v_fileTable     t_fileTable;    -- Stores the backuppiece names
[url=http://www.oraclepoint.com]XZor4DPcvOraclePointB2hNVHDiY[/url]


      v_maxPieces     number:=1;    -- Number of backuppieces in backupset
[url=http://www.oraclepoint.com]awlverVwvOraclePoint3faR3z6kt[/url]

    BEGIN

    -- Initialise the filetable & number of backup pieces in the backupset
[url=http://www.oraclepoint.com]0zMv1DTEZOraclePointaH8yiuZUO[/url]


    -- This section of code MUST be edited to reflect the customers available
[url=http://www.oraclepoint.com]GpB3ihTzaOraclePointJvA4v1Fgr[/url]

    -- backupset before the procedure is compiled and run. In this example, the

    -- archivelog backupset consists of 2 pieces:
[url=http://www.oraclepoint.com]IzviP4fEcOraclePointPewelbge0[/url]


       v_fileTable(1):='al_s20_p1';
[url=http://www.oraclepoint.com]Exze7lezWOraclePointV64CEtym0[/url]

       v_fileTable(2):='al_s20_p2';

       v_maxPieces:=2;
[url=http://www.oraclepoint.com]rIDJYi73JOraclePointXZnXdbN9X[/url]


    -- Allocate a device. In this example, I have specified 'sbt_tape' as I am
[url=http://www.oraclepoint.com]ydNKyJD1NOraclePointxozwW81gV[/url]

    -- reading backuppieces from the media manager. If the backuppiece is on disk,

    -- specify type=>null
[url=http://www.oraclepoint.com]YcOi1oLOIOraclePointnbGAPjOaY[/url]


      v_dev:=sys.dbms_backup_restore.deviceAllocate(type=>'sbt_tape',ident=>'t1');
[url=http://www.oraclepoint.com]XePlR5aDQOraclePointY4wuSP01G[/url]

    -- Begin the restore conversation

      sys.dbms_backup_restore.restoreSetArchivedLog(destination=>'/support2/OFA_V804/app/oracle/admin/arch/arch_');
[url=http://www.oraclepoint.com]nCUvpv3qBOraclePointc5b1S7G5N[/url]


    -- Specify where the archivelog is to be recreated
[url=http://www.oraclepoint.com]AURQtLDddOraclePointTcTZFVt2A[/url]

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

    -- Restore the archivelog
[url=http://www.oraclepoint.com]furgMm9D5OraclePoint5JyIJJZa3[/url]


      FOR i IN 1..v_maxPieces LOOP
[url=http://www.oraclepoint.com]leWEyyYN5OraclePointu8wvcgc0t[/url]

        sys.dbms_backup_restore.restoreBackupPiece(done=>v_done,handle=>v_fileTable(i),params=>null);

        IF v_done THEN
[url=http://www.oraclepoint.com]E9w037yBGOraclePoint9bg2CBNHz[/url]

          GOTO all_done;
        END IF;
[url=http://www.oraclepoint.com]CfD8PAtAdOraclePointQddAhbwhU[/url]

      END LOOP;

    <<all_done>>
[url=http://www.oraclepoint.com]tVVzTwWKyOraclePointXY6NabQXr[/url]


    -- Deallocate the device
[url=http://www.oraclepoint.com]RHsuYLOYtOraclePointpLQ05mVt6[/url]

     sys.dbms_backup_restore.deviceDeallocate;

    END;
[url=http://www.oraclepoint.com]HGG7de3q5OraclePointT8SBOat0z[/url]


    /

_________________________________________________________________________________
[url=http://www.oraclepoint.com]5OOo4Z54UOraclePointgOEcVKiSn[/url]


For restoring multiple archives from a backupset, add a loop
  around  sys.dbms_backup_restore.restoreArchivedLog()
[url=http://www.oraclepoint.com]CKU8eSQfhOraclePointrPhgJvuyo[/url]


  for seq in <min seq#>..<max seq#> loop
    sys.dbms_backup_restore.restoreArchivedLog(thread=>1,
[url=http://www.oraclepoint.com]KshePvirHOraclePointsPZWSkrQE[/url]

                                             sequence=>seq);
  end loop
[url=http://www.oraclepoint.com]AhkhOzEv0OraclePointzgxeqgCKv[/url]

6. A typical scenario

  A customer has backupsets consisting of:
[url=http://www.oraclepoint.com]ytc7csVzBOraclePoint7gSBhzlEE[/url]

    o. an incremental level 0 database backup
    o. an incremental level 2 database backup
    o. archivelogs from the time of the level 2 backup to the current time
[url=http://www.oraclepoint.com]bJ1b0WPdCOraclePointvgNgU80QZ[/url]

  The target database and recovery catalog have been irretrievably lost.

  In this situation, the following steps should be followed (using the  
[url=http://www.oraclepoint.com]smPujvCkSOraclePoint3MX8ogxFf[/url]

  above anonymous blocks):
    1. Start the target instance (nomount)
    2. Restore the latest controlfile, ideally from the same backupset as
[url=http://www.oraclepoint.com]KU0NGgbn2OraclePointYnHyVuDGT[/url]

       the last incremental to be restored (make further copies if necessary
       as per the init.ora)
    3. Mount the database
[url=http://www.oraclepoint.com]zI5IBGf0uOraclePointCx1i8KiKR[/url]

    4. Restore the datafiles from the level 0 backupset
    5. Restore (apply) the datafiles from the level 2 backupset
    6. Restore the archivelogs from the archivelog backupset
[url=http://www.oraclepoint.com]Em56AhDz4OraclePointy30HrIBzJ[/url]

    7. Using tradtional v7 recovery techniques, recover the database  
       (until cancel using backup controlfile)
    8. Open the database (resetlogs)
[url=http://www.oraclepoint.com]IVJ3Y7t74OraclePoint4eELiqFer[/url]

    9. Rebuild the recovery catalog & re-register the target database
   10. Make backups of the target database and recovery catalog database
[url=http://www.oraclepoint.com]mhggVYfdGOraclePointnf7xnR7gp[/url]


7. Errors
[url=http://www.oraclepoint.com]3PmwJH1UqOraclePointhaKODrujD[/url]

 7.1 ORA-19615 & ORA-19613 when attempting to extract files

     Errorstack:
[url=http://www.oraclepoint.com]JEhPsCLgqOraclePointdcNJVdvIn[/url]

       ORA-19583: conversation terminated due to error
       ORA-19615: some files not found in backup set
       ORA-19613: datafile <file#> not found in backup set
[url=http://www.oraclepoint.com]308igYsvbOraclePointafAeoFB5x[/url]

       ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 1043
       ORA-06512: at line 40
[url=http://www.oraclepoint.com]DFTuiw8rIOraclePointadRDVQB4w[/url]

     The problem is that one or more backup pieces specified in the
     v_fileTable table contain NO blocks for the datafile that you are  
     trying to extract.  
[url=http://www.oraclepoint.com]amh2DD2hsOraclePoint7jmunrEXQ[/url]


     For example, I may have run an RMAN backup and allocated 2 channels to
     backup the (4 datafile) database. This will create 2 backupsets.
[url=http://www.oraclepoint.com]2V9AwbRzwOraclePointh2qURT3IX[/url]


______________________________________________________________________________________
[url=http://www.oraclepoint.com]6A5n8eQsHOraclePoint8xeOo1Mom[/url]


    .                       
[url=http://www.oraclepoint.com]n6cadTHxlOraclePointapuxlvsOt[/url]


                                                     +- Backup piece 1a
[url=http://www.oraclepoint.com]MfbUdOzr4OraclePointp4hRhdt98[/url]


                     +- (Backupset 1) Datafiles 1,2 -+
[url=http://www.oraclepoint.com]DFupgaZUBOraclePointKDQ4QvVkO[/url]


                     |                               +- Backup piece 2a
[url=http://www.oraclepoint.com]ja6cFzAXXOraclePointeHVbLbM18[/url]


           Database -+
[url=http://www.oraclepoint.com]mPSnaV4UlOraclePointppM4Pmzss[/url]


                     |                               +- Backup piece 1b
[url=http://www.oraclepoint.com]otGBNNXpYOraclePointy2OveeEH5[/url]


                     +- (Backupset 2) Datafiles 3,4 -+
[url=http://www.oraclepoint.com]ZBOBq5OkJOraclePoint2Z2jEkpGy[/url]


                                                     +- Backup piece 2b
[url=http://www.oraclepoint.com]4ddRRVgDzOraclePointAH76h9Kjp[/url]


_______________________________________________________________________________________
[url=http://www.oraclepoint.com]ExPNopFOtOraclePointp41dxT8Fl[/url]


Although the backup pieces may contain blocks from all datafiles
     associated with their backupset, they will not contain blocks from a  
[url=http://www.oraclepoint.com]SlpHmxEiVOraclePointDs5swr9AW[/url]

     different backupset i.e. pieces 1a and 1b will NOT contain blocks from  
     datafiles 3 or 4.
[url=http://www.oraclepoint.com]oFkXveOPROraclePointiMWJf9znk[/url]

     If I want to restore datafile 1, and include either backup pieces 1b or
     2b in v_fileTable, I will get the errorstack above.
[url=http://www.oraclepoint.com]mrI9u23dnOraclePointkbo7Fugdf[/url]

     This is why it is important to know what files are in what backupset.
     The original RMAN backup log will help here.
[url=http://www.oraclepoint.com]ArvSP9oZdOraclePointmPGN3yW1j[/url]


8. Things to be done
[url=http://www.oraclepoint.com]NsC2SefPkOraclePointPvEvwwgEC[/url]

  8.1. Error handling
       If the procedures fail with an unhandled exception (quite likely, as
       no exception handlers have been set up), the allocated device does not
[url=http://www.oraclepoint.com]etb9VqFjjOraclePoint46ZcIIfAb[/url]

       get deallocated. This is unfriendly (the user must exit & restart the
       session) and will be addressed

[Lasted edited on 2008-07-30 18:23 R.Wang ]


Tags: case restore 

2008-07-29 16:08
  Grade this thread



Similar Threads Forum Author Replies Views Last Post
My Practical Approach to Create Domain Index
Oracle Case Study R.Wang 0 438  2010-05-13 15:45
My Practical Approach to Create Domain Index
Oracle Database Administration R.Wang 0 231  2010-05-13 15:44
Duplicating Oracle Database with RMAN on Remote Server
Oracle Case Study R.Wang 0 343  2010-05-10 00:00
How to Change Character Set to UTF8 for Oracle Database?
Oracle Case Study R.Wang 0 386  2010-05-09 23:53
Use LogMiner to locate Archive Logs Flow
Oracle Case Study R.Wang 3 2102  2009-08-01 11:08

  Quick Response
Title:
Content:




Upload: Disable
Username:
Password:
  



Recommend to a friend Print Article Mode





 


Powered by BMForum Powered by BMForum 2007 5.6 RSS Feed  
Processed in 0.11712193 second(s),8 queries  
Top