ora_full_backup.sh

#!/bin/bash

BACKUP_DIR="/home/yshuai/works/2008-12-10_NPS61_ED2/backup_recovery/02_cluster/backup_scripts/gen2"

. /home/oracle/.bash_profile

 

# test if db on this node

sqlplus -L testuser/testuser | grep ORA-01017 > /dev/null

if [ $? -ne 0 ]; then

  now=`date '+%Y-%m-%d %H:%M:%S'`

  echo "Error: Oracle not start, can not perform full backup! ($now)" |tee -a $BACKUP_DIR/rmanErr.log

  exit

fi

 

# rotate logs

for i in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

do

next=`expr $i + 1`

test -f $BACKUP_DIR/rman.log.$i && mv $BACKUP_DIR/rman.log.$i $BACKUP_DIR/rman.log.$next

done

 

#rman script

$ORACLE_HOME/bin/rman target / <<EOF > $BACKUP_DIR/rman.log.0

configure retention policy to recovery window of 15 days;

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$BACKUP_DIR/%F';

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '$BACKUP_DIR/%U';

crosscheck archivelog all;

backup database plus archivelog;

delete noprompt archivelog all backed up 2 times to device type disk;

crosscheck backup;

delete noprompt obsolete;

exit;

EOF

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章