cd /home/oracle/scripts
vi rman.sh
. /home/oracle/scripts/kfptdb
BAKPATH=/backup/RMAN
DBNAME=`sqlplus -S / as sysdba <<EOF
set feedback off
set heading off
set pagesize 0
set linesize 100
set trimspool on
select value from v\\$parameter where name ='db_name';
EOF`
if [ ! -d "$BAKPATH/$DBNAME/" ]; then
mkdir -p "$BAKPATH/$DBNAME/"
fi
if [ ! -d "$BAKPATH/log" ]; then
mkdir -p "$BAKPATH/log"
fi
rman target / log=$BAKPATH/log/$DBNAME-full_`date +%Y%m%d%H%M`.log<<!
run{
allocate channel d1 device type disk;
allocate channel d2 device type disk;
allocate channel d3 device type disk;
allocate channel d4 device type disk;
allocate channel d5 device type disk;
allocate channel d6 device type disk;
backup as compressed backupset database format '$BAKPATH/$DBNAME/%d_Full_%s_%t';
sql 'alter system archive log current';
backup as compressed backupset archivelog all format '$BAKPATH/$DBNAME/%d_Arch_%s_%t' not backed up 1 times;
backup spfile format '$BAKPATH/$DBNAME/%d_SP_%s_%t';
backup current controlfile format '$BAKPATH/$DBNAME/%d_C_%s_%t';
RELEASE CHANNEL d1;
RELEASE CHANNEL d2;
RELEASE CHANNEL d3;
RELEASE CHANNEL d4;
RELEASE CHANNEL d5;
RELEASE CHANNEL d6;
}
crosscheck archivelog all;
crosscheck backupset;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt backup completed before 'sysdate-7';
delete noprompt force archivelog all completed before 'sysdate-7';
list backup summary;
exit
!
find $BAKPATH/log/ -name "*.log" -mtime +30 |xargs rm -rf 1> /dev/null 2>&1
30 22 * * * sh /home/oracle/scripts/kfptdb.sh > /dev/null 2>&1
30 23 * * * sh /home/oracle/scripts/zhfwdb.sh > /dev/null 2>&1