Copy files from ASM diskgroup to nonASM filesystem


Below is a script to accomplish copying files from ASM to nonASM (on Linux).  Below example is for copying archivelogs from inside ASM to NAS mount.

#!/bin/bash
#
# This script copies files from FRA on ASM to local disk
#
ORACLE_SID=+ASM1 
ORACLE_HOME=/opt/grid/11.2.0.2  ##{Grid OH}
ASMLS=/users/apps/oracle/asm_ls.txt ##{ASM files list}
FRA=+FRA/CODREP/ARCHIVELOG/`date +%Y_%m_%d` ##{source location of files}
LOCALBACKUPDIR=/opt/dbadmin/CODREP/ARCHIVE_COPY  ##{destination filesystem}
LOG=/users/apps/oracle/asm_log.txt ##{log file}
#
# Get the list of files
#
$ORACLE_HOME/bin/asmcmd > $ASMLS <<EOF
ls $FRA
exit
EOF
#
# Clean the list by removing "ASMCMD>"
#
sed -i 's/ASMCMD> //g' $ASMLS
##cat $ASMLS
echo `date` > $LOG
#
# Copy files one by one
#

for FILENAME in `cat $ASMLS`
do
if [[ ! -f $LOCALBACKUPDIR/${FILENAME} ]]
then
$ORACLE_HOME/bin/asmcmd >> $LOG <<EOF
cp $FRA/$FILENAME $LOCALBACKUPDIR
EOF
fi
done
echo `date` >> $LOG

Comments

varun yadav said…
Thanks you so much for this script.

Popular posts from this blog

RMAN-10038: database session for channel prm3 terminated unexpectedly

ORA-17630: Mismatch in the remote file protocol version client 2 server 3

ORA-00338: log {n} of thread {n} is more recent than control file