#! /bin/ksh # ----------------------------------------------------------------------- # Filename: rmanarch.ksh # Purpose: Recatalog archived logs that were marked as deleted with the # "change archivelog all validate/corsscheck;" command and # later moved back to the archlog directory to be backed-up. # Author: Frank Naude, Oracle FAQ # Notes: # # DBA's frequently move files from the database archive destination to # prevent this directory from filling up causing database freezes. The # "change archivelog all validate/crosscheck;" command is then issued # to mark missing archivelog files as DELETED in the catalog. Successive # backups will not backup these "deleted" files. # # If one later move these files back to the archive log destination, they # will not be backed up unless you re-catalog them. This script will # generate the commands necessary to re-catalog these files. # ----------------------------------------------------------------------- SYSPSW=change_on_install # Get the database archlog directory ARCHDIR=`sqlplus -s sys/${SYSPSW} <<-EOF set echo off feed off head off pages 0 termout off select value from sys.v_\\$parameter where name = 'log_archive_dest'; exit; EOF` print "Checking archlog dir $ARCHDIR for 'deleted' files...\n" # List all files in the archlog directory and check against the DB. find ${ARCHDIR}* -type f | while read f do RMANCMD=`sqlplus -s sys/${SYSPSW} <<-EOF set echo off feed off head off pages 0 termout off select 'CATALOG ARCHIVELOG '''||name||''';' from sys.v_\\$archived_log where name = '$f' and deleted = 'YES'; exit; EOF` if [ "${RMANCMD}" ]; then print $RMANCMD fi done print "" print "Please run the above RMAN command(s) to recatalog archived log files" print "marked as deleted and later moved back to the archlog directory." print ""