RMAN全备脚本
export today=date +%Y%m%d%H%M
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
export MYPATH=/backup/rman/"$ORACLE_SID"/"$today"
if [[ ! -e "$MYPATH" ]]
then
mkdir -p "$MYPATH";
fi
$ORACLEHOME/bin/rman target / log=$MYPATH/full"$ORACLESID""$today".log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup as compressed backupset full database tag 'dbfull' format '$MYPATH/%d-%T-%U.full';
sql 'alter system archive log current';
backup archivelog all format '$MYPATH/%d-%T-%U.arc' delete input;
backup current controlfile format '$MYPATH/%d-%T-%U.ctf';
backup spfile format '$MYPATH/%d-%T-%U.spt';
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit;
EOF