ADSM-L

Re: deleting obsolete Oracle backuppice

2000-08-25 06:49:20
Subject: Re: deleting obsolete Oracle backuppice
From: Leopold Hameder <lha AT CARUS DOT DE>
Date: Fri, 25 Aug 2000 12:48:36 +0200
Hi,

if you do not, so issue
allocate channel for delete type ''SBT_TAPE'';
before issueing
change backuppiece....delete
and after this
release channel;

If this doesn't help, my explanation for this is the following:

"change backuppiece ...delete" marks the Record in the Recovery-Catalog as
deleted but does not remove it.
And maybe you can do this several.
You can remove the Records with the SQL-Script below.
But no Guarantee - I'm not Oracle-Admin.


prgrmanc.sql

  -------------------- BEGIN ----------------------------------
  Rem
  Rem $Header: prgrmanc.sql 28-jul-98.02:01:35 fsanchez Exp $
  Rem
  Rem prgrmanc.sql
  Rem
  Rem Copyright (c) Oracle Corporation 1995-1998. All Rights Reserved.
  Rem
  Rem    NAME
  Rem      prgrmanc.sql
  Rem    DESCRIPTION
  Rem      Purges from RMAN Recovery Catalog the records marked as deleted
by
  Rem      the user.
  Rem
  Rem      It is up to the user to mark the records as deleted using the
  Rem      RMAN command: CHANGE ... DELETE
  Rem
  Rem      The Media Manager catalog is not updated by this script, only
  Rem      the recovery catalog
  Rem
  Rem      Currently the records removed by this script might be
reinserted
  Rem      if a "resync from backup controlfile" is performed, this might
undo
  Rem      both the CHANGE...DELETE and the physical delete of the record.

  Rem
  Rem      This script removes records from the following tables:
  Rem          AL
  Rem          RLH
  Rem          BP
  Rem          BS
  Rem          BCF
  Rem          BDF
  Rem          BCB
  Rem          BRL
  Rem          CCF
  Rem          CDF
  Rem          CCB
  Rem
  Rem    MODIFIED   (MM/DD/YY)
  Rem    fsanchez    07/28/98 - Creation
  Rem
  Rem   NOTES
  Rem      To avoid using large amounts of rollback the script commits
  Rem      every 500 records by default
  Rem      This value can be changed by modyfing the following line
  define csize=500

  set verify off
  declare
      i       number;
      key     number;
      thr     number;
      seq     number;
      lscn    number;
      eoc     boolean;
      cursor alrecs is
          select dbinc_key, thread#, sequence#, low_scn
            from al
           where status = 'D'
             for update of status;
      cursor bprecs is
          select bp_key
            from bp
           where status = 'D'
             for update of status;
      cursor bsrecs is
          select bs_key
            from bs
           where not exists
               (select null
                  from bp
                 where bs.bs_key = bp.bs_key)
             for update of status;
      cursor ccfrecs is
          select ccf_key
            from ccf
           where status = 'D'
             for update of status;
      cursor cdfrecs is
          select cdf_key
            from cdf
           where status = 'D'
             for update of status;
  begin
      -- Step 1) Remove al records marked as deleted.
      --         If a rlh record is found, also remove it
      eoc := false;
      while not eoc loop
          open alrecs;
          i := 0;
          while not eoc and i <= &&csize loop
              fetch alrecs into key, thr, seq, lscn;
              if not alrecs%NOTFOUND then
                  -- Delete the log history for this archivelog
                  delete rlh
                   where dbinc_key = key
                     and thread# = thr
                     and sequence# = seq
                     and low_scn = lscn;
                  -- Delete the current al record
                  delete al
                   where current of alrecs;
                  -- Increment counter
                  i := i + 1;
              else
                  -- signal that we have processed all al records
                  eoc := true;
              end if;
          end loop;
          --- close and commit changes
          close alrecs;
          commit;
      end loop;

      -- Step 2) Delete the bp records marked as deleted
      eoc := false;
      while not eoc loop
          open bprecs;
          i := 0;
          while not eoc and i <= &&csize loop
              fetch bprecs into key;
              if not bprecs%NOTFOUND then
                  -- Delete the current bp record
                  delete bp
                   where current of bprecs;
                  -- Increment counter
                  i := i + 1;
              else
                  -- signal that we have processed all bp records
                  eoc := true;
              end if;
          end loop;
          --- close and commit changes
          close bprecs;
          commit;
      end loop;

      -- Step 3) Remove the bs records that do not have any pieces left.
      --         When the bs record is removed, the  bcf, bdf, bcb and brl


      --         records are removed automatically by the integrity
  constraints
      eoc := false;
      while not eoc loop
          open bsrecs;
          i := 0;
          while not eoc and i <= &&csize loop
              fetch bsrecs into key;
              if not bsrecs%NOTFOUND then
                  -- Delete the current bs record, that in turn will
remove
                  -- records from bcf, bdf and brl.
                  -- If a bdf record is removed, the bcb record will
                  -- also be deleted.
                  delete bs
                   where current of bsrecs;
                  -- Increment counter
                  i := i + 1;
              else
                  -- signal that we have processed all bs records
                  eoc := true;
              end if;
          end loop;
          --- close and commit changes
          close bsrecs;
          commit;
      end loop;

      -- Step 4) Remove the ccf records that are marked as deleted
      eoc := false;
      while not eoc loop
          open ccfrecs;
          i := 0;
          while not eoc and i <= &&csize loop
              fetch ccfrecs into key;
              if not ccfrecs%NOTFOUND then
                  -- Delete the current ccf record
                  delete ccf
                   where current of ccfrecs;
                  -- Increment counter
                  i := i + 1;
              else
                  -- signal that we have processed all bs records
                  eoc := true;
              end if;
          end loop;
          --- close and commit changes
          close ccfrecs;
          commit;
      end loop;

      -- Step 5) Remove the cdf records that are marked as deleted
      eoc := false;
      while not eoc loop
          open cdfrecs;
          i := 0;
          while not eoc and i <= &&csize loop
              fetch cdfrecs into key;
              if not cdfrecs%NOTFOUND then
                  -- Delete the current cdf record.  This in turn will
                  -- remove ccb records by integrity constraints
                  delete cdf
                   where current of cdfrecs;
                  -- Increment counter
                  i := i + 1;
              else
                  -- signal that we have processed all bs records
                  eoc := true;
              end if;
          end loop;
          --- close and commit changes
          close cdfrecs;
          commit;
      end loop;
  end;
  /
  ------------------------------------ END



"Wong, Han Neng" schrieb:

>  Hi All,
>
>  I have encounter some problem in deleting obsolete Oracle backuppice.
>
>  ## I am submitting change  to delete the obsolete backuppiece
>  RMAN> change backuppiece 'dydf_405640820_768_1' delete;
>
>  RMAN-03022: compiling command: change
>  RMAN-03023: executing command: change
>  RMAN-08073: deleted backup piece
>  RMAN-08517: backup piece handle=dydf_405640820_768_1
>  recid=738 stamp=405640825
>  RMAN-03023: executing command: partial resync
>
>  ## Again, I submit the same .
>  RMAN> change backuppiece 'dydf_405640820_768_1' delete;
>
>  RMAN-03022: compiling command: change
>  RMAN-03023: executing command: change
>  RMAN-08073: deleted backup piece
>  RMAN-08517: backup piece handle=dydf_405640820_768_1
>  recid=738 stamp=405640825
>  RMAN-03023: executing command: partial resync
>
>  ?? Why the same result appear ? What wrong here ?
>  Any one can help me.
>  Thanks
>
>  Wong Han Neng
>  Systems Administrator
>  The Westin Stamford & Westin Plaza

--
With Regards / Mit freundlichen Gruessen
With Regards / Mit freundlichen Gruessen

Leopold Hameder

c.a.r.u.s. InformationsSysteme AG
Borsteler Chaussee 49
22453 Hamburg
Tel.: +49 40 514 35 - 0
Fax: +49 40 514 35 - 111
E-Mail: mailto:Leopold.Hameder AT carus DOT de
WWW: http://www.carus.de
<Prev in Thread] Current Thread [Next in Thread>