This website use cookies to help you have a superior and more admissible browsing experience on the website.
Loading...
Oracle Recovery Manager (RMAN) is an Oracle’s native backup and recovery tool. People backup Oracle database using RMAN to protect data files, control files, SPILE, redo logs, etc. But sometimes, you will want to delete RMAN backup due to:
When you run DELETE BACKUP, RMAN does two things:
1. Physically deletes the backup piece(s) from disk (or tells the media manager to mark tape space as reusable)
2. Removes the corresponding rows from the control file and/or recovery catalog.
If you delete backup files at the operating system level (rm or del), RMAN’s control file still thinks those backups exist. CROSSCHECK followed by DELETE EXPIRED cleans up the records — but cannot bring back physical files.
For tape backups, the media manager (Oracle Secure Backup or a third‑party SBT library) decides whether the physical tape file is truly deleted. Often, it’s simply marked as reusable.
The table list the core RMAN delete syntax for quick reference. Also, we will give a detailed and step-by-step guide on how to use them in different scenarios.
|
Command |
What It Does |
When to Use |
|
DELETE BACKUP |
Deletes backup sets or pieces from disk/tape and removes catalog records. Physically removes files. |
You know exactly which backup key(s) to remove. Use with specific keys — never run without filters. |
|
DELETE BACKUP OF |
Deletes backups of a specific database object (datafile, tablespace, archivelog, controlfile). |
You want to remove backups of a single tablespace or all archivelog backups, but keep other backups intact. |
|
DELETE OBSOLETE |
Deletes backups that are no longer needed based on your configured retention policy (RECOVERY WINDOW or REDUNDANCY). |
Scheduled cleanup. Run daily after setting a retention policy. Always preview with REPORT OBSOLETE first. |
|
DELETE EXPIRED |
Removes catalog records for backups that CROSSCHECK marked as EXPIRED (physical file missing). Does not delete files — only metadata. |
Physical backup files were deleted outside RMAN (OS rm or del), and you need to clean up the catalog so restores don’t fail. |
RMAN’s DELETE BACKUP has no direct UNTIL TIME clause. But you can use LIST BACKUP to identify keys, then delete individually.
Here is an example:
# Find backups older than 7 days
RMAN> LIST BACKUP OF DATABASE COMPLETED BEFORE 'SYSDATE-7';
-- Note the BS Key values, then delete each
RMAN> DELETE BACKUP 2048;
RMAN> DELETE BACKUP 2049;
For scripting, use REPORT OBSOLETE with a temporary retention policy change — but that risks deleting too much. Most DBAs write a small PL/SQL loop over V$BACKUP_PIECE for precise date‑based deletion.
RMAN> DELETE BACKUP OF ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-3';
This removes only the backup pieces (the copies RMAN made). The original archived log files (e.g., /u01/arch/arch_1_123.arc) remain untouched. Use this when your backup storage is full, but you still need the original logs for point‑in‑time recovery or because they haven’t yet been copied to a different destination.
RMAN> DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-3' BACKED UP 1 TIMES TO DEVICE TYPE DISK;
Physically removes the .arc or .log files from the archive log directory. The backup pieces remain untouched.
Note:
To delete an unwanted RMAN backup piece, use the syntax:
RMAN> DELETE BACKUPPIECE 'full_path_to_backup_piece';
What follows BACKUPPIECE is the complete filesystem path or tape handle of the backup piece. You find this path by running LIST BACKUP OF DATABASE.
RMAN removes exactly that backup piece from disk and deletes its catalog record. Other backup pieces in the same backup set will be not deleted.
If you want to automate the deletion of RMAN backups, set a retention policy.
Example to automatically delete backups in RMAN that over 7 days. Change the number as you want.
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
And if you want a daily script:
#!/bin/bash
rman target / catalog rman/rman@catdb <<EOF
REPORT OBSOLETE;
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
DELETE NOPROMPT EXPIRED BACKUP;
EOF
Sometimes, you may get some errors when deleting your backups. Here are the solutions.
This happens usually when deleting tape backups.
Fix it with:
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
RMAN> DELETE OBSOLETE;
CROSSCHECK + DELETE EXPIRED removes the catalog entry. If the backup still shows as AVAILABLE after crosscheck, the file may exist but be unreadable (permissions, corruption). Use VALIDATE BACKUP before assuming it’s missing.
Managing backup in a cron job works for a single or several databases. But when you manage dozens of Oracle instances across physical, virtual, and cloud environments, scripting everything will be too complicated.
i2Backup, developed by Info2soft, takes a different approach. It’s an enterprise backup platform that handles Oracle backup lifecycle management, including automated cleanup, through a unified interface, so you don’t need to write and maintain RMAN script for every database.
Administrators just define backup schedule and define policies in a central web console. Then the software handles the rest. It will perform backup tasks following the backup preset schedule. When backup files become obsolete, i2Backup can be configured to remove them automatically based on your retention rules.
Key capabilities for Oracle Backup Management:
Now you can get a 60-day free trial:
This is all about how to delete expired backup in RMAN. It is not complex:
You can also set a retention policy to automate the process in a daily script. And if you manage more than a handful of Oracle databases, consider managing backup with a centralized platform like Info2soft’s i2Backup.