如何清理控制文件中的备份信息

如何清理控制文件中的备份信息

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Control File Copy     2      22-APR-13          /tmp/contrlfile.
Control File Copy     3      22-APR-13          /tmp/controlfile.bkp
Control File Copy     4      23-JUL-13          /home/oracle/control01.ctl
Backup Set           21     29-JUL-13        
  Backup Piece       21     29-JUL-13          /home/oracle/backup/0poful7g_1_1
Control File Copy     5      30-JUL-13          /home/oracle/controlfile.ctl
Backup Set           22     29-JUL-13        
  Backup Piece       22     29-JUL-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130729-02
Backup Set           23     31-JUL-13        
  Backup Piece       23     31-JUL-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130731-00
Backup Set           24     08-AUG-13        
  Backup Piece       24     08-AUG-13          /home/oracle/xff_0sogqjrp_1_1
Backup Set           25     08-AUG-13        
  Backup Piece       25     08-AUG-13          /home/oracle/xff_0togqjuu_1_1
Backup Set           26     08-AUG-13        
  Backup Piece       26     08-AUG-13          /home/oracle/xff_ctl.bck
Backup Set           27     08-AUG-13        
  Backup Piece       27     08-AUG-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130808-00
Backup Set           29     09-AUG-13        
  Backup Piece       29     09-AUG-13          /home/oracle/backup/10ogqt93_1_1
Backup Set           28     09-AUG-13        
  Backup Piece       28     09-AUG-13          /home/oracle/backup/11ogqt93_1_1
Backup Set           30     09-AUG-13        
  Backup Piece       30     09-AUG-13          /home/oracle/backup/12ogqte1_1_1
Backup Set           32     09-AUG-13        
  Backup Piece       32     09-AUG-13          /home/oracle/backup/13ogqte2_1_1
Backup Set           31     09-AUG-13        
  Backup Piece       31     09-AUG-13          /home/oracle/backup/14ogqtfg_1_1
Backup Set           33     09-AUG-13        
  Backup Piece       33     09-AUG-13          /home/oracle/backup/15ogqtg2_1_1
Control File Copy     6      11-AUG-13          /home/oracle/conctlfile.ctl
Backup Set           34     09-AUG-13        
  Backup Piece       34     09-AUG-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130809-00
Control File Copy     7      11-AUG-13          /home/oracle/con.ctl
Backup Set           36     11-AUG-13        
  Backup Piece       36     11-AUG-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-00
Backup Set           37     11-AUG-13        
  Backup Piece       37     11-AUG-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-01
Backup Set           38     20-AUG-13        
  Backup Piece       38     20-AUG-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130820-00
Backup Set           39     12-NOV-13        
  Backup Piece       39     12-NOV-13          /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20131112-00


如果由于某些原因,crosscheck不能执行,或者执行后报错delete 不能删除备份信息
可以使用 dbms_backup_restore pl/sql包来删除备份信息

SQL> select 'dbms_backup_restore.deleteBackupPiece(' || recid || ',' || stamp || ',''' || HANDLE || ''',' || SET_STAMP || ',' || SET_COUNT || ',' || PIECE# || ');' sqlt
  2        from v$backup_piece
  3      where recid between 21 and 39;


dbms_backup_restore.deleteBackupPiece(21,822039792,'/home/oracle/backup/0poful7g_1_1',822039792,25,1);
dbms_backup_restore.deleteBackupPiece(22,822039903,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130729-02',822039902,26,1);
dbms_backup_restore.deleteBackupPiece(23,822183442,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130731-00',822183441,27,1);
dbms_backup_restore.deleteBackupPiece(24,822955898,'/home/oracle/xff_0sogqjrp_1_1',822955897,28,1);
dbms_backup_restore.deleteBackupPiece(25,822956001,'/home/oracle/xff_0togqjuu_1_1',822955998,29,1);
dbms_backup_restore.deleteBackupPiece(26,822956399,'/home/oracle/xff_ctl.bck',822956396,30,1);
dbms_backup_restore.deleteBackupPiece(27,822956401,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130808-00',822956400,31,1);
dbms_backup_restore.deleteBackupPiece(28,822965540,'/home/oracle/backup/11ogqt93_1_1',822965539,33,1);
dbms_backup_restore.deleteBackupPiece(29,822965540,'/home/oracle/backup/10ogqt93_1_1',822965539,32,1);
dbms_backup_restore.deleteBackupPiece(30,822965698,'/home/oracle/backup/12ogqte1_1_1',822965697,34,1);
dbms_backup_restore.deleteBackupPiece(31,822965745,'/home/oracle/backup/14ogqtfg_1_1',822965744,36,1);
dbms_backup_restore.deleteBackupPiece(32,822965698,'/home/oracle/backup/13ogqte2_1_1',822965698,35,1);
dbms_backup_restore.deleteBackupPiece(33,822965765,'/home/oracle/backup/15ogqtg2_1_1',822965762,37,1);
dbms_backup_restore.deleteBackupPiece(34,822965767,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130809-00',822965767,38,1);
dbms_backup_restore.deleteBackupPiece(35,823211972,'/home/oracle/backup/17oh2du3_1_1',823211971,39,1);
dbms_backup_restore.deleteBackupPiece(36,823212092,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-00',823212090,40,1);
dbms_backup_restore.deleteBackupPiece(37,823218052,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-01',823218051,42,1);
dbms_backup_restore.deleteBackupPiece(38,823943456,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130820-00',823943454,43,1);
dbms_backup_restore.deleteBackupPiece(39,831333434,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20131112-00',831333432,44,1);

19 rows selected.

SQL> exec dbms_backup_restore.deleteBackupPiece(21,822039792,'/home/oracle/backup/0poful7g_1_1',822039792,25,1);
dbms_backup_restore.deleteBackupPiece(22,822039903,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130729-02',822039902,26,1);
dbms_backup_restore.deleteBackupPiece(23,822183442,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130731-00',822183441,27,1);
dbms_backup_restore.deleteBackupPiece(24,822955898,'/home/oracle/xff_0sogqjrp_1_1',822955897,28,1);
dbms_backup_restore.deleteBackupPiece(25,822956001,'/home/oracle/xff_0togqjuu_1_1',822955998,29,1);
dbms_backup_restore.deleteBackupPiece(26,822956399,'/home/oracle/xff_ctl.bck',822956396,30,1);

PL/SQL procedure successfully completed.

SQL> dbms_backup_restore.deleteBackupPiece(27,822956401,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130808-00',822956400,31,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SQL> SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(28,822965540,'/home/oracle/backup/11ogqt93_1_1',822965539,33,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(29,822965540,'/home/oracle/backup/10ogqt93_1_1',822965539,32,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SQL> dbms_backup_restore.deleteBackupPiece(30,822965698,'/home/oracle/backup/12ogqte1_1_1',822965697,34,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(31,822965745,'/home/oracle/backup/14ogqtfg_1_1',822965744,36,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(32,822965698,'/home/oracle/backup/13ogqte2_1_1',822965698,35,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(33,822965765,'/home/oracle/backup/15ogqtg2_1_1',822965762,37,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SQL> dbms_backup_restore.deleteBackupPiece(34,822965767,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130809-00',822965767,38,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(35,823211972,'/home/oracle/backup/17oh2du3_1_1',823211971,39,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(36,823212092,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-00',823212090,40,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(37,823218052,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-01',823218051,42,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SP2-0044: For a list of known commands enter HELP
and to leave enter EXIT.
SQL> dbms_backup_restore.deleteBackupPiece(38,823943456,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130820-00',823943454,43,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL> dbms_backup_restore.deleteBackupPiece(39,831333434,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20131112-00',831333432,44,1);
SP2-0734: unknown command beginning "dbms_backu..." - rest of line ignored.
SQL>
SQL> exec dbms_backup_restore.deleteBackupPiece(21,822039792,'/home/oracle/backup/0poful7g_1_1',822039792,25,1);
exec dbms_backup_restore.deleteBackupPiece(22,822039903,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130729-02',822039902,26,1);
exec dbms_backup_restore.deleteBackupPiece(23,822183442,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130731-00',822183441,27,1);
exec dbms_backup_restore.deleteBackupPiece(24,822955898,'/home/oracle/xff_0sogqjrp_1_1',822955897,28,1);
exec dbms_backup_restore.deleteBackupPiece(25,822956001,'/home/oracle/xff_0togqjuu_1_1',822955998,29,1);

PL/SQL procedure successfully completed.

SQL> exec dbms_backup_restore.deleteBackupPiece(26,822956399,'/home/oracle/xff_ctl.bck',822956396,30,1);
exec dbms_backup_restore.deleteBackupPiece(27,822956401,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130808-00',822956400,31,1);
exec dbms_backup_restore.deleteBackupPiece(28,822965540,'/home/oracle/backup/11ogqt93_1_1',822965539,33,1);
exec dbms_backup_restore.deleteBackupPiece(29,822965540,'/home/oracle/backup/10ogqt93_1_1',822965539,32,1);
exec dbms_backup_restore.deleteBackupPiece(30,822965698,'/home/oracle/backup/12ogqte1_1_1',822965697,34,1);
exec dbms_backup_restore.deleteBackupPiece(31,822965745,'/home/oracle/backup/14ogqtfg_1_1',822965744,36,1);
exec dbms_backup_restore.deleteBackupPiece(32,822965698,'/home/oracle/backup/13ogqte2_1_1',822965698,35,1);
exec dbms_backup_restore.deleteBackupPiece(33,822965765,'/home/oracle/backup/15ogqtg2_1_1',822965762,37,1);
exec dbms_backup_restore.deleteBackupPiece(34,822965767,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130809-00',822965767,38,1);
exec dbms_backup_restore.deleteBackupPiece(35,823211972,'/home/oracle/backup/17oh2du3_1_1',823211971,39,1);
exec dbms_backup_restore.deleteBackupPiece(36,823212092,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-00',823212090,40,1);
exec dbms_backup_restore.deleteBackupPiece(37,823218052,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130811-01',823218051,42,1);
exec dbms_backup_restore.deleteBackupPiece(38,823943456,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20130820-00',823943454,43,1);
exec dbms_backup_restore.deleteBackupPiece(39,831333434,'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20131112-00',831333432,44,1);
PL/SQL procedure successfully completed.

SQL> PL/SQL procedure successfully completed.
。。。。。。


查看下 其中的某个备份片:

RMAN> list backupst 39

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "all, archivelog, backed, backuppiece, backupset, backup, completed, controlfilecopy, copy, datafilecopy, db_unique_name, device, expired, failure, foreign, global, incarnation, like, proxy, recoverable, restore, script, tag"
RMAN-01008: the bad identifier was: backupst
RMAN-01007: at line 1 column 6 file: standard input

RMAN> list backupset 39;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
39      Full    9.70M      DISK        00:00:03     12-NOV-13     
        BP Key: 39   Status: AVAILABLE  Compressed: NO  Tag: TAG20131112T215712
        Piece Name: /u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-239394037-20131112-00
  Control File Included: Ckp SCN: 2979051      Ckp time: 12-NOV-13
  SPFILE Included: Modification time: 12-NOV-13
  SPFILE db_unique_name: MYNEWDB

RMAN> list backupset 39;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 11/19/2013 20:26:50
RMAN-06160: no backup pieces found for backup set key: 39

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Control File Copy     2      22-APR-13          /tmp/contrlfile.
Control File Copy     3      22-APR-13          /tmp/controlfile.bkp
Control File Copy     4      23-JUL-13          /home/oracle/control01.ctl
Control File Copy     5      30-JUL-13          /home/oracle/controlfile.ctl
Control File Copy     6      11-AUG-13          /home/oracle/conctlfile.ctl
Control File Copy     7      11-AUG-13          /home/oracle/con.ctl

 

你可能感兴趣的:(DBRecovery)