oracledba.help
Scripts

asm2os.arclogs.sh

<- Scripts

#!/bin/bash
# File: asm2os.arclogs.sh
# 2017.10.19: Initial Version

# Local Path Vars
XFER_BASE="/u01/xfer/sb_files"
OS_ARCLOG_BASE="$XFER_BASE/ARCHIVELOG"

# ASM Path Vars
ASM_ARCLOG_BASE="+FRA/ORADB/ARCHIVELOG"
ASM_ARCLOG_DIRS="2017_10_18 2017_10_19 2017_10_20 2017_10_23"


# Confirmation
printf "+----------------------------------------+\n" 
printf "| About to Copy ArcLogs From ASM to OS   |\n"
printf "| Existing local ArcLogs will be purged. |\n"
printf "+----------------------------------------+\n"
printf "XFER_BASE: $OS_ARCLOG_BASE\n\n"
read -p "Are you sure want to continue [y\n]? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
    exit 1
fi
printf "\n\n"


# Init Dirs
printf "Init Dirs: $XFER_BASE...\n\n"
rm -rf $OS_ARCLOG_BASE
mkdir -p $OS_ARCLOG_BASE
chmod -R 776 $OS_ARCLOG_BASE
#read -p "Press [Enter] key to continue."


# Copy Files
for dir in $ASM_ARCLOG_DIRS
do
   # OS Actions
   printf "Processing: $dir\n"
   sOSFullPath="$OS_ARCLOG_BASE/$dir"
   mkdir $sOSFullPath

   # ASM Actions
   sASMFullDirPath="$ASM_ARCLOG_BASE/$dir"
   for f in $(asmcmd ls $sASMFullDirPath)
   do
      asmcmd cp $sASMFullDirPath/$f $sOSFullPath/;   
   done   
done

# End
printf "\nProcess Completed \n\n"
printf "You can copy ArcLogs to remote system.\n"
printf "Ex: scp -r $OS_ARCLOG_BASE oracle@lnx02:/u01/xfer/sb_files/ \n\n"