Loading...

We've detected that your browser language is Chinese. Would you like to visit our Chinese website? [ Dismiss ]
By: Dylan

Why Delete Backups in RMAN

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:

  • Free up backup storage: A few weeks of full backups plus archivelogs can fill your Fast Recovery Area. When that happens, the database can freeze. Just delete unnecessary backups to free up storage.
  • The catalog gets out of sync. If you delete backup files at the OS level (bypassing RMAN). RMAN still lists them as AVAILABLE. Restores then fail because files don’t exist. You delete expired catalog records to clean up the mess.
  • Retention policies change. Business requirements shift from “keep 30 days” to “keep 7 days.” Those older backups become obsolete. They sit there wasting space until you run DELETE OBSOLETE.

delete rman backup

What is RMAN Backup Deletion?

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.

How to Delete Backups in RMAN Step by Step

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.

Delete backups older than 7 days or a specific date

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:

sql
# 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.

Delete only archivelog backups

  • If you want to free space used by backup pieces of archived logs, but keep the original archived log files on disk, use:
sql
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.

  • If you want to delete the original archived datafile copy, use DELETE ARCHIVELOG, not DELETE BACKUP OF ARCHIVELOG.
bash
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:

  1. For safety, only delete original archived logs after you have confirmed they are backed up (use the BACKED UP … TIMES clause).
  2. If you actually need to free up disk space from the archive log target location, running the `DELETE BACKUP OF ARCHIVELOG` command will not free up any space. Conversely, if you only want to delete backup files, running the `DELETE ARCHIVELOG` command will delete the wrong files.

    Manually delete a specific backup piece

    To delete an unwanted RMAN backup piece, use the syntax:

    bash
    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.

    Warning: Deleting a backup piece makes the entire backup set incomplete. If you delete one piece of a multi‑piece backup set, you can no longer restore from that set. Only use this when you are certain the piece is corrupt or obsolete.

    Automating RMAN backup cleanup with retention policies

    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.

    sql
    RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

    And if you want a daily script:

    bash
    #!/bin/bash
    rman target / catalog rman/rman@catdb <<EOF
    REPORT OBSOLETE;
    DELETE NOPROMPT OBSOLETE;
    CROSSCHECK BACKUP;
    DELETE NOPROMPT EXPIRED BACKUP;
    EOF

    Troubleshooting common problem when deleting backups in RMAN

    Sometimes, you may get some errors when deleting your backups. Here are the solutions.

    1. “RMAN‑06091: no channel allocated for maintenance”

    This happens usually when deleting tape backups.

    Fix it with:

    bash
    RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
    RMAN> DELETE OBSOLETE;

    2. Recovery catelog shows a backup, but the physical file is missing

    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.

    Centralized Backup Management with i2Backup

    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:

    • Centralized retention policy: Set retention windows or redundancy rules once, apply them across all Oracle instances, and let the system handle cleanup without per-database cron jobs.
    • Granular recovery options: Restore at the CDB, PDB, archive log, or control file level without pulling an entire backup set. Point-in-time recovery based on timestamps are also supported.
    • Multiple storage targets: Back up to local disks, tape libraries, NAS, or object storage, with built-in deduplication to reduce footprint.
    • Immutable backups for ransomware protection: i2Backup uses immutable storage and anti-tampering drivers that prevent unauthorized deletion.

    Now you can get a 60-day free trial:

    FREE Trial for 60-Day

    Conclusion

    This is all about how to delete expired backup in RMAN. It is not complex:

    • Use DELETE OBSOLETE for scheduled cleanup based on your retention policy.
    • Use CROSSCHECK + DELETE EXPIRED when physical files go missing outside RMAN.
    • Use DELETE BACKUP only when you know the exact backup key or piece.
    • Never delete backup files at the OS level. That breaks the catalog and leaves you with unrecoverable space and unreliable restores.

    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.

    Dylan has 8+ years of experience in enterprise data management, server optimization, and disaster recovery. He specializes in translating complex technical concepts into actionable guides for IT administrators and DevOps teams, with a focus on data security, cloud migration, and business continuity.

    More Related Articles

    Table of Contents:
    Stay Updated on Latest Tips
    Subscribe to our newsletter for the latest insights, news, exclusive content. You can unsubscribe at any time.
    Subscribe
    Ready to Enhance Business Data Security?
    Start a 60-day free trial or view demo to see how Info2soft protects enterprise data.
    {{ country.name }}
    Please fill out the form and submit it, our customer service representative will contact you soon.
    By submitting this form, I confirm that I have read and agree to the Privacy Notice.
    {{ isSubmitting ? 'Submitting...' : 'Submit' }}