os2asm.sh
#!/bin/bash # File: os2asm.sh # 2017.10.19: Initial Version # # Comments: cp technique based on bug 7658491 and Bug 7012038, # we should not use OMF names in asmcmd cp. # Per Doc ID 1468566.1 # Local Path Vars XFER_BASE="/u01/xfer/sb_files" DATAFILE="$XFER_BASE/DATAFILE" TEMPFILE="$XFER_BASE/TEMPFILE" ONLINELOG1="$XFER_BASE/ONLINELOG1" ONLINELOG2="$XFER_BASE/ONLINELOG2" # ASM Path Vars ASM_DATAFILE="+DATA/oradb_sb/DATAFILE" ASM_TEMPFILE="+DATA/oradb_sb/TEMPFILE" ASM_ONLINELOG1="+DATA/oradb_sb/ONLINELOG" ASM_ONLINELOG2="+FRA/ORADB_SB/ONLINELOG" # Confirmation printf "+------------------------------------+\n" printf "| About to Copy Files to ASM from OS |\n" printf "+------------------------------------+\n" printf "XFER_BASE: $XFER_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 File Rename Script RENAME_SCRIPT="/tmp/os2asm.rename.sql" if [ -f $RENAME_SCRIPT ]; then rm -f $RENAME_SCRIPT fi touch $RENAME_SCRIPT # Copy Files printf "Processing: $ASM_DATAFILE\n" for i in $DATAFILE/* do #Just Get File Name (not full path) fn=${i##*/} # Extract Name Without Incarnation Characters f2=${fn::-14} asmcmd cp $i $ASM_DATAFILE/$f2 # Create Rename Script Entry echo "ALTER DATABASE RENAME FILE '$ASM_DATAFILE/$f2' to '$ASM_DATAFILE/$fn';" >> $RENAME_SCRIPT done printf "Processing: $ASM_TEMPFILE\n" for i in $TEMPFILE/* do fn=${i##*/} f2=${fn::-14} asmcmd cp $i $ASM_TEMPFILE/$f2 echo "ALTER DATABASE RENAME FILE '$ASM_TEMPFILE/$f2' to '$ASM_TEMPFILE/$fn';" >> $RENAME_SCRIPT done printf "Processing: $ASM_ONLINELOG1\n" for i in $ONLINELOG1/* do fn=${i##*/} f2=${fn::-14} asmcmd cp $i $ASM_ONLINELOG1/$f2 echo "ALTER DATABASE RENAME FILE '$ASM_ONLINELOG1/$f2' to '$ASM_ONLINELOG1/$fn';" >> $RENAME_SCRIPT done printf "Processing: $ASM_ONLINELOG2\n" for i in $ONLINELOG2/* do fn=${i##*/} f2=${fn::-14} asmcmd cp $i $ASM_ONLINELOG2/$f2 echo "ALTER DATABASE RENAME FILE '$ASM_ONLINELOG2/$f2' to '$ASM_ONLINELOG2/$fn';" >> $RENAME_SCRIPT done # End printf "\nProcess Completed \n\n"