Ben the DBA

How To Erase RMAN Backup And Archivelogs

Check the Space Usage

First, we need to locate the database recovery file destination:


SHOW PARAMETER DB_RECOVERY_FILE_DEST

Output:

Now, let's see if they are taking too much space:


du -hs /u03/FRA/*/

Output:

Erase the Archivelogs

Let's erase one archivelog for this example:


[oracle@dataguard-rogue01 2024_08_01]$ ls -ltr
total 80552
 -rw-r-----. 1 oracle oinstall    4096  1 août  04:02 o1_mf_1_1797_mbov5m4f_.arc
 -rw-r-----. 1 oracle oinstall 2510848  1 août  04:32 o1_mf_1_1798_mbowxr53_.arc
 -rw-r-----. 1 oracle oinstall 4920320  1 août  05:02 o1_mf_1_1799_mboyoz4c_.arc
 -rw-r-----. 1 oracle oinstall 1146368  1 août  05:32 o1_mf_1_1800_mbp0g675_.arc
 -rw-r-----. 1 oracle oinstall 4737536  1 août  06:02 o1_mf_1_1801_mbp26f6v_.arc
 -rw-r-----. 1 oracle oinstall 1145344  1 août  06:32 o1_mf_1_1802_mbp3yq91_.arc
 -rw-r-----. 1 oracle oinstall 4755456  1 août  07:02 o1_mf_1_1803_mbp5pyy3_.arc
 -rw-r-----. 1 oracle oinstall 1132544  1 août  07:32 o1_mf_1_1804_mbp7h602_.arc
 -rw-r-----. 1 oracle oinstall 4812288  1 août  08:02 o1_mf_1_1805_mbp97hx9_.arc
 -rw-r-----. 1 oracle oinstall 1150976  1 août  08:32 o1_mf_1_1806_mbpbzpp5_.arc
 -rw-r-----. 1 oracle oinstall 4826112  1 août  09:02 o1_mf_1_1807_mbpdqy37_.arc
 -rw-r-----. 1 oracle oinstall 1155584  1 août  09:32 o1_mf_1_1808_mbpgj6tn_.arc
 -rw-r-----. 1 oracle oinstall 4715008  1 août  10:02 o1_mf_1_1809_mbpj8fsj_.arc
 -rw-r-----. 1 oracle oinstall 2465280  1 août  10:32 o1_mf_1_1810_mbpl0qrj_.arc
 -rw-r-----. 1 oracle oinstall 4966400  1 août  11:02 o1_mf_1_1811_mbpmryy5_.arc
 -rw-r-----. 1 oracle oinstall 1150976  1 août  11:32 o1_mf_1_1812_mbpok67p_.arc
 -rw-r-----. 1 oracle oinstall 4852736  1 août  12:02 o1_mf_1_1813_mbpq9fdj_.arc
 -rw-r-----. 1 oracle oinstall 1231360  1 août  12:32 o1_mf_1_1814_mbps1qbb_.arc
 -rw-r-----. 1 oracle oinstall 4782592  1 août  13:02 o1_mf_1_1815_mbptsy8z_.arc
 -rw-r-----. 1 oracle oinstall 1139712  1 août  13:32 o1_mf_1_1816_mbpwl5jm_.arc
 -rw-r-----. 1 oracle oinstall 5159424  1 août  14:02 o1_mf_1_1817_mbpybhgc_.arc
 -rw-r-----. 1 oracle oinstall 1190400  1 août  14:32 o1_mf_1_1818_mbq02p9n_.arc
 -rw-r-----. 1 oracle oinstall 5058048  1 août  15:02 o1_mf_1_1819_mbq1txgy_.arc
 -rw-r-----. 1 oracle oinstall 1143808  1 août  15:32 o1_mf_1_1820_mbq3m7l5_.arc
 -rw-r-----. 1 oracle oinstall 5115904  1 août  16:02 o1_mf_1_1821_mbq5cgwg_.arc
 -rw-r-----. 1 oracle oinstall 2356224  1 août  16:32 o1_mf_1_1822_mbq73ppx_.arc
 -rw-r-----. 1 oracle oinstall 4819456  1 août  17:02 o1_mf_1_1823_mbq8vxpv_.arc
[oracle@dataguard-rogue01 2024_08_01]$ rm -f o1_mf_1_1797_mbov5m4f_.arc
[oracle@dataguard-rogue01 2024_08_01]$ pwd
/u03/FRA/ZERG/archivelog/2024_08_01

Erase the oldest archivelogs and keep a few (3-4) if you are using a solution like Data Guard or DbVisit.

Connect to RMAN and Update the Catalog

Connect to RMAN:


rman TARGET /

Update the RMAN catalog:


RMAN> crosscheck archivelog all;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=30 device type=DISK
validation failed for archived log
archived log file name=/u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1797_mbov5m4f_.arc RECID=3329 STAMP=1175832147
validation succeeded for archived log
archived log file name=/u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1798_mbowxr53_.arc RECID=3331 STAMP=1175833944
validation succeeded for archived log
archived log file name=/u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1799_mboyoz4c_.arc RECID=3333 STAMP=1175835743
validation succeeded for archived log
[...]
validation succeeded for archived log
archived log file name=/u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1822_mbq73ppx_.arc RECID=3379 STAMP=1175877142
validation succeeded for archived log
archived log file name=/u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1823_mbq8vxpv_.arc RECID=3381 STAMP=1175878941
Crosschecked 27 objects

Delete the expired archivelogs:


RMAN> DELETE EXPIRED ARCHIVELOG ALL;

Output:


released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=30 device type=DISK
List of Archived Log Copies for database with db_unique_name ZERG
=====================================================================

Key     Thrd Seq     S Low Time
|------- ---- ------- - ---------
3329    1    1797    X 01-AUG-24
Name: /u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1797_mbov5m4f_.arc


Do you really want to delete the above objects (enter YES or NO)? YES
deleted archived log
archived log file name=/u03/FRA/ZERG/archivelog/2024_08_01/o1_mf_1_1797_mbov5m4f_.arc RECID=3329 STAMP=1175832147
Deleted 1 EXPIRED objects

Now the archivelog is deleted from the system and the RMAN catalog.

Erase the Backups

First, erase the backups manually. You should erase the oldest ones.

Then, update the RMAN catalog:


RMAN> crosscheck backup;

Output:


using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_26/o1_mf_nnndf_DBHOT_FULL_mb60s7s7_.bkp RECID=189 STAMP=1175313607
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_26/o1_mf_annnn_ARCHLOG_mb60vqlm_.bkp RECID=191 STAMP=1175313687
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_27/o1_mf_nnndf_DBHOT_FULL_mb8o595g_.bkp RECID=195 STAMP=1175400009
[...]
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/FRA/ZERG/autobackup/ctrl_spfile_c-4159565523-20240801-01 RECID=228 STAMP=1175832186
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/FRA/ZERG/backupset/2024_08_01/o1_mf_ncnnf_CTRLSTDBY_mbov6wv8_.bkp RECID=229 STAMP=1175832188
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u03/FRA/ZERG/autobackup/ctrl_spfile_c-4159565523-20240801-02 RECID=230 STAMP=1175832190
Crosschecked 23 objects

Now, delete the expired backups:


RMAN> delete noprompt expired backup;

Output:


using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
189     189     1   1   EXPIRED     DISK        /u03/FRA/ZERG/backupset/2024_07_26/o1_mf_nnndf_DBHOT_FULL_mb60s7s7_.bkp
191     191     1   1   EXPIRED     DISK        /u03/FRA/ZERG/backupset/2024_07_26/o1_mf_annnn_ARCHLOG_mb60vqlm_.bkp
195     195     1   1   EXPIRED     DISK        /u03/FRA/ZERG/backupset/2024_07_27/o1_mf_nnndf_DBHOT_FULL_mb8o595g_.bkp
197     197     1   1   EXPIRED     DISK        /u03/FRA/ZERG/backupset/2024_07_27/o1_mf_annnn_ARCHLOG_mb8o7gr4_.bkp
201     201     1   1   EXPIRED     DISK        /u03/FRA/ZERG/backupset/2024_07_28/o1_mf_nnndf_DBHOT_FULL_mbc9k8ff_.bkp
203     203     1   1   EXPIRED     DISK        /u03/FRA/ZERG/backupset/2024_07_28/o1_mf_annnn_ARCHLOG_mbc9n34k_.bkp
deleted backup piece
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_26/o1_mf_nnndf_DBHOT_FULL_mb60s7s7_.bkp RECID=189 STAMP=1175313607
deleted backup piece
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_26/o1_mf_annnn_ARCHLOG_mb60vqlm_.bkp RECID=191 STAMP=1175313687
deleted backup piece
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_27/o1_mf_nnndf_DBHOT_FULL_mb8o595g_.bkp RECID=195 STAMP=1175400009
deleted backup piece
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_27/o1_mf_annnn_ARCHLOG_mb8o7gr4_.bkp RECID=197 STAMP=1175400078
deleted backup piece
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_28/o1_mf_nnndf_DBHOT_FULL_mbc9k8ff_.bkp RECID=201 STAMP=1175486408
deleted backup piece
backup piece handle=/u03/FRA/ZERG/backupset/2024_07_28/o1_mf_annnn_ARCHLOG_mbc9n34k_.bkp RECID=203 STAMP=1175486499
Deleted 6 EXPIRED objects

TOC

Check the Space Usage
Erase the Archivelogs
Connect to RMAN and Update the Catalog
Erase the Backups