• 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 delete archives from only 1 archive destination when 2 or more are in use

by admin

If you want to delete the archives of 1 LOG_ARCHIVE_DEST using rman command and want to keep the archive logs from other LOG_ARCHIVE_DEST_[n] for some other purpose, then use DELETE LIKE-clause in RMAN.

This way you can maintain the archives in one location and keep the same copy of the archives in another location. Consider the below example:

1. You have 2 archive destinations to keep the archive logs.

/u01/app/oracle/arch/test2
/u01/app/oracle/test/arch2
SQL> show parameter log_archive_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string location=/u01/app/oracle/arch/test2
log_archive_dest_5 string location=/u01/app/oracle/test/arch

2. All the archives are on the above two locations.

$ ls -ltr /u01/app/oracle/test/arch/*
total 248
-rw-r----- 1 oracle oinstall 212480 Mar 14 13:26 1_32_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_33_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_35_776337487.dbf
-rw-r----- 1 oracle oinstall 3584 Mar 14 13:26 1_34_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_36_776337487.dbf
$ ls -lrt /u01/app/oracle/arch/test2/*
-rw-r----- 1 oracle oinstall 212480 Mar 14 13:26 1_32_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_33_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_35_776337487.dbf
-rw-r----- 1 oracle oinstall 3584 Mar 14 13:26 1_34_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_36_776337487.dbf

3. Now backup the archived redologs from ‘/u01/app/oracle/arch/test2’ and delete them afterwards, but do not delete the archives from the other location : ‘/u01/app/oracle/test/arch’. Example command:

RMAN> backup archivelog like '/u01/app/oracle/arch/test2%' delete input;"

Output:

Recovery Manager: Release 11.2.0.2.0 - Production on Wed Mar 14 13:30:30 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=859136735)

RMAN> backup archivelog like '/u01/app/oracle/arch/test2%' delete input;

Starting backup at 14-MAR-2012 13:31:50
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=23 RECID=32 STAMP=777885413
input archived log thread=1 sequence=24 RECID=33 STAMP=777885414
input archived log thread=1 sequence=25 RECID=35 STAMP=777885416
input archived log thread=1 sequence=26 RECID=34 STAMP=777885416
input archived log thread=1 sequence=27 RECID=36 STAMP=777907018
channel ORA_DISK_1: starting piece 1 at 14-MAR-2012 13:31:54

channel ORA_DISK_1: finished piece 1 at 14-MAR-2012 13:32:59
piece handle=/u01/app/oracle/fast_recovery_area/TEST2/backupset/2012_03_14/o1_mf_annnn_TAG20120314T133152_7p0n3ldh_.bkp tag=TAG20120314T133152 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/arch/test2/1_32_776337487.dbf RECID=41 STAMP=777907585
archived log file name=/u01/app/oracle/arch/test2/1_33_776337487.dbf RECID=43 STAMP=777907587
archived log file name=/u01/app/oracle/arch/test2/1_34_776337487.dbf RECID=45 STAMP=777907588
archived log file name=/u01/app/oracle/arch/test2/1_35_776337487.dbf RECID=47 STAMP=777907588
archived log file name=/u01/app/oracle/arch/test2/1_36_776337487.dbf RECID=49 STAMP=777907589
Finished backup at 14-MAR-2012 13:33:00

Recovery Manager complete.

4. RMAN deleted the files in “/u01/app/oracle/arch/test2” and not in “/u01/app/oracle/test/arch”. You can verify the result as shown below.

$ ls -lrt /u01/app/oracle/arch/test2/*
total 0
$ ls -lrt /u01/app/oracle/test/arch/*
total 248
-rw-r----- 1 oracle oinstall 212480 Mar 14 13:26 1_32_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_33_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_35_776337487.dbf
-rw-r----- 1 oracle oinstall 3584 Mar 14 13:26 1_34_776337487.dbf
-rw-r----- 1 oracle oinstall 1024 Mar 14 13:26 1_36_776337487.dbf

Filed Under: oracle, RMAN

Some more articles you might also be interested in …

  1. How to Define PDB Listeners With Different Ports In a Oracle database Multitenant Setup
  2. Oracle Database 12c2 : CPU_COUNT is Wrong
  3. How to Move OCR, Vote Disk File, ASM SPILE to new Diskgroup
  4. SQL: Difference between delete and truncate
  5. Interview Questions : Oracle Flex ASM 12c
  6. Oracle Database : Shutdown Basics (How to Shutdown Oracle Database)
  7. Find Oracle RAC OCR & voting disk location
  8. How To Resize An ACFS Filesystem/ASM Volume (ADVM)
  9. What roles can be set as default for a user in Oracle Database
  10. Oracle 11G RMAN – Understanding UNDO backup optimisation

You May Also Like

Primary Sidebar

Recent Posts

  • fprintd-delete Command Examples in Linux
  • fprintd-delete: command not found
  • foreman: command not found
  • foreman Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright