• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to backup and delete archivelogs older than # number of days

by admin

Question : How can one achieve the following while using RMAN to backup the archived logs?
Back up all archived redo logs until specified time and delete them after backing up, and also back up all the other archived redo logs that were not backed up before – all this with a single RMAN command.

Solution

Backup archivelogs older than 10 days and delete them

First let us look at the command to backup all archived logs older than 10 days and delete them:

RMAN> run { 
       allocate channel t1 type disk;
       backup 
          format '/recover/oracle/%d/arc_%d_%t_%s'
          archivelog until time 'sysdate-10' delete input; 
       }

The above will back up all archived logs older than 10 days and then delete them.

NOTE : The logs newer than 10 days are not backed up using the above method. To backup them as well use the next method.

Backup all logs and delete logs older than 10 days only

If you would like to back up all archived logs and delete only the ones that are older than 10 days, you can do the following:

RMAN> run { 
       allocate channel t1 type disk;
       backup 
          format '/recover/oracle/%d/arc_%d_%t_%s'
          archivelog all 
          archivelog until time 'sysdate-10' delete input;
       }

Filed Under: oracle

Some more articles you might also be interested in …

  1. How to Termibate a Session on a Specific Instance of Oracle RAC
  2. How to recreate the spfile for RAC instances where the spfile is stored in ASM
  3. Patching and Upgrading Databases in Oracle Data Guard Configuration
  4. Oracle GoldenGate: Extract Sample Parameter File
  5. Oracle ASM 12c – New Features with examples
  6. How to Convert STANDARD ASM to FLEX ASM in 12C
  7. ORA-27125: unable to create shared memory segment; Error: 28: No space left on device
  8. How to Backup and Restore Java Classes and Privileges only in Oracle Database
  9. Define redo log files in an Oracle RAC environment
  10. Oracle Data Guard Security Enhancement – SYSDG Administration Privilege

You May Also Like

Primary Sidebar

Recent Posts

  • vgextend Command Examples in Linux
  • setpci command – configure PCI device
  • db_load command – generate db database
  • bsdtar command – Read and write tape archive files

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright