Monday, 11 November 2019

Archivelog,and RMAN Backup copy from ASM to Local filesystem

15 08 * * *  /u04/MasterDB/scripts/grid_scripts/asm_rman_backup.sh >>/u04/MasterDB/smrrac_backup/SMRRAC_FULL.log | mail -s "RMAN ASM Bacckup to filesystem" varun.yadav@mind-infotech.com

0 */1 * * * /u04/MasterDB/scripts/grid_scripts/
>>//u04/MasterDB/scripts/grid_scripts/asm_ls.txt | mail -s "Archivelog smrrac " varun.yadav@mind-infotech.com

################# asm_rman_backup.sh Script ############################
grid@sgdcplm02:/home/oracle> cat /u04/MasterDB/scripts/grid_scripts/asm_rman_backup.sh
#!/bin/bash

#

# This script copies files from FRA on ASM to local disk

#

export ORACLE_SID=+ASM1

export ORACLE_HOME=/u01/app/12.1.0/grid  ##{Grid OH}
export PATH=$ORACLE_HOME/perl/bin:$PATH
ASMLS=/u04/MasterDB/scripts/grid_scripts/asm_rman.txt ##{ASM files list}

FRA=+BACKUP/rman_bkp ##{source location of files}

LOCALBACKUPDIR=/u04/MasterDB/smrrac_backup  ##{destination filesystem}

LOG=/u04/MasterDB/scripts/grid_scripts/asm_rman1.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
grid@sgdcplm02:/home/oracle>
#################################################################################

##########################  asm_archive.sh SCRIPTS ############################### 

grid@sgdcplm02:/home/oracle> cat /u04/MasterDB/scripts/grid_scripts/asm_archive.sh
#!/bin/bash

#

# This script copies files from FRA on ASM to local disk

#

export ORACLE_SID=+ASM1
#export ORACLE_HOME=/u01/app/12.1.0/grid  ##{Grid OH}
export ORACLE_HOME=/u01/app/12.1.0/grid/
#export PATH=$ORACLE_HOME/OPatch:$PATH:$ORACLE_HOME/bin
export PATH=$ORACLE_HOME/perl/bin:$PATH

ASMLS=/u04/MasterDB/scripts/grid_scripts/asm_ls.txt ##{ASM files list}

FRA=+FRA2/archivelog ##{source location of files}

LOCALBACKUPDIR=/u04/MasterDB/smrrac_archivelog  ##{destination filesystem}

LOG=/u04/MasterDB/scripts/grid_scripts/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
grid@sgdcplm02:/home/oracle>

No comments:

Post a Comment