Sunday, December 22, 2013

Oracle 10g:Backup archives on hourly basis



Backup archives on hourly basis



To get full recovery of database,We backup archives on hourly basis.

For this,

Use this script for backup.

Check comments for better understanding...

#!/usr/bin/ksh

# Go to backup location.
cd /rmanbck/arch

ddy=`date +%a`
dt=`date +%Y%m%d`

#last archive was backed up sequence
lastredono=`ls -rt *arch*.log|tail -1|sed 's/^.*arch_//;s/[.]log//'|awk -F_ '{print $2}'`
fno=`expr ${lastredono} \- 2`
#From Archive destination, Find the max sequence generations
tno=`find /oracle/arch -name "*.arch" -print|sort|tail -1|sed 's@/oracle/arch/@@'|awk -F_ '{print $1}'`
FNAME=${dt}_${ddy}_arch_${fno}_${tno}
echo $FNAME
rman target / trace /rmanbck/arch/$FNAME.log << EOF
run
{
ALLOCATE CHANNEL disk3 DEVICE TYPE DISK;
backup as compressed backupset FORMAT '/rmanbck/arch/%T_${ddy}_arch_${fno}_${tno}_%U.set' archivelog from sequence ${fno} until sequence ${tno};
release channel disk3;
}
EOF
exit;