Mir Sayeed Hassan – Oracle Blog

Oracle DBA – Tips & Techniques | Learn with real-time examples

  • Translate

  • It’s Me






  • My Certificates

  • Links

    My Acclaim Certification : Credly Profile
    My Oracle ACE Pro Profile

  • Achievements

    Awarded Top 100 Oracle Blogs from Worldwide - #RANK 39
  • VISITORS COUNT

  • Verified International Academic Qualification from World Education Service (WES)

    Verified International Academic Qualification from World Education Service (WES)

  • Jobs

How to delete the backup which is no longer needed or obsolete in Oracle database using RMAN

Posted by Mir Sayeed Hassan on July 20th, 2020

How to delete the backup which is no longer needed or obsolete in Oracle database using RMAN

Note: You can delete the backup which is not needed as per the rman configuration policy set

Check the RMAN Configuration policy

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name TESTDB123 are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_testdb123.f'; # default

Note:

In case if you want to specify delete obsolete, then all the obsolete backup will be deleted based on the current RMAN Configuration retention policy

If you want to specify with the retention policy, then use the below command

delete obsolete redundancy=1;
delete obsolete recovery windows of 7 days

Here we are deleteing all the obsolete backup from database

RMAN> delete obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=316 device type=DISK
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 33 14-JUL-20
Backup Piece 33 14-JUL-20 /backup/new_testdb/controlnew.ctl
Backup Set 41 20-JUL-20
Backup Piece 57 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165209_hkc3lgsw_.bkp
Backup Set 43 20-JUL-20
Backup Piece 59 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165220_hkc3lz0o_.bkp
Backup Set 44 20-JUL-20
Backup Piece 60 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_nnndf_TAG20200720T165401_hkc3m03f_.bkp
Backup Set 45 20-JUL-20
Backup Piece 61 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165401_hkc3mh6t_.bkp
Backup Set 47 20-JUL-20
Backup Piece 63 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165434_hkc3mzdb_.bkp
Backup Set 49 20-JUL-20
Backup Piece 65 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncnnf_TAG20200720T165845_hkc3n1m0_.bkp
Backup Set 49 20-JUL-20
Backup Piece 49 20-JUL-20 /u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncnnf_TAG20200720T165845_hkc3hy7x_.bkp

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/backup/new_testdb/controlnew.ctl RECID=33 STAMP=1045776390
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165209_hkc3lgsw_.bkp RECID=57 STAMP=1046278806
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165220_hkc3lz0o_.bkp RECID=59 STAMP=1046278822
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_nnndf_TAG20200720T165401_hkc3m03f_.bkp RECID=60 STAMP=1046278824
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165401_hkc3mh6t_.bkp RECID=61 STAMP=1046278839
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncsnf_TAG20200720T165434_hkc3mzdb_.bkp RECID=63 STAMP=1046278855
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncnnf_TAG20200720T165845_hkc3n1m0_.bkp RECID=65 STAMP=1046278857
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/TESTDB123/backupset/2020_07_20/o1_mf_ncnnf_TAG20200720T165845_hkc3hy7x_.bkp RECID=49 STAMP=1046278726
Deleted 8 objects

====Hence tested & verified in our test env=====