rmanfullbak.bat
rman target sys/passw0rd nocatalog cmdfile 'd:rmanbakfullbackup.rman' log 'd:rmanbakfullbackup.log'
fullbackup.rman
run {
allocate channel c1 type disk;
backup full tag 'dbfull' format 'e:rmanbakora_o_%u_%s_%p' database ;
sql 'alter system archive log current' ;
backup(archivelog all delete input format 'e:orabakrman_bkora_a_%u_%s_%p');
backup format ‘e:orabakrman_bkcntrl_%u_%s_%p' CURRENT CONTROLFILE;
release channel c1;
}
db_back.cmd
run
{
sql 'alter system archive log current';
allocate channel c1 type disk;
backup full
(database format "/oracle/oradata/cslhb_rman/%d_db_%u_p%p_s%s"
);
release channel c1;
}
db_back.sh
#!/bin/sh
##################################################
# filename: db_back.sh
#
# location: /etc/app/
#
# function: Do database backup and maintance
# Created by: Founder Order Company
#
# Usage : db_back.sh ORACLE_SID
#
###################################################
if [ ! $# -eq 2 ]
then
echo "Usage: $0 ORACLE_SID RmanCmdFile "
echo "Example: /etc/app/db_back.sh CSLZJ /etc/app/db_back.cmd"
exit 1
fi
FIND=/usr/bin/find
XARGS=/usr/bin/xargs
RM="/usr/bin/rm -f"
RMAN=$ORACLE_HOME/bin/rman
ORACLE_SID=$1; export ORACLE_SID
ORACLE_HOME=/oracle/product/10.1.0/db_1;export ORACLE_HOME
DBNAME=`echo $ORACLE_SID|tr "[A-Z]" "[a-z]"`
SCRIPTFILE=$2
DBDIR=/oracle/oradata/${DBNAME}_rman
ARCDIR1=/oracle/oradata/${DBNAME}_arch1
ARCDIR2=/oracle/oradata/${DBNAME}_arch2
DBRETNUM=4 #The numbers of Database backup copies retended, Note: 2 files per copy.
DBRETDAYS=15 #The days of database backup copies retended
ARCRETNUM1=30 #The numbers of archive logs retended in the first archive destination
ARCRETNUM2=60 #The numbers of archive logs retended in the second archive destination
ARCRETDAYS1=15 #The days of database backup copies retended in the first archive destination
ARCRETDAYS2=30 #The days of database backup copies retended in the second archive destination
#check if Oracle is running on the host
$ORACLE_HOME/bin/sqlplus -S /nolog >/dev/null <WHENEVER SQLERROR EXIT 1
connect / as sysdba;
select 1 from dba_data_files;
exit
EOF
if [ $? -eq 1 ]
then
echo "`date`: Warning: The database $ORACLE_SID is not running on the host, Do nothing"
exit 1
fi
echo "#####################################################################################"
echo "# "
echo "# `date` Start database backup "
echo "# "
echo "#####################################################################################"
# Do database rman backup
$RMAN target "/ " cmdfile $SCRIPTFILE
if [ $? -eq 0 ]
then
echo "#####################################################################################"
echo "# "
echo "# `date` Complete database backup "
echo "# "
echo "#####################################################################################"
CURNUM=`$FIND $DBDIR -name "${ORACLE_SID}*" |wc -l`
if [ $CURNUM -gt $DBRETNUM ]
then
#do db backup deletion
$FIND $DBDIR -name "${ORACLE_SID}*" -a -mtime +$DBRETDAYS | $XARGS $RM
fi
fi
#Delete first archive destination Archive
CURNUM=`$FIND $ARCDIR1 -name "${ORACLE_SID}*.ARC" |wc -l`
if [ $CURNUM -gt $ARCRETNUM1 ]
then
$FIND $ARCDIR1 -name "${ORACLE_SID}*.ARC" -a -mtime +$ARCRETDAYS1 | $XARGS $RM
fi
#Delete second archive destination Archive
CURNUM=`$FIND $ARCDIR2 -name "${ORACLE_SID}*.ARC" |wc -l`
if [ $CURNUM -gt $ARCRETNUM2 ]
then
$FIND $ARCDIR2 -name "${ORACLE_SID}*.ARC" -a -mtime +$ARCRETDAYS2 | $XARGS $RM
fi
echo "#####################################################################################"
echo "# "
echo "# `date` Start TSM BACKUP DISK-->TAPELIB "
echo "# "
echo "#####################################################################################"
#do TSM backup: db backup file->tape lib
/usr/tivoli/tsm/client/ba/bin/dsmc i $DBDIR $ARCDIR2
echo "#####################################################################################"
echo "# "
echo "# `date` Complete TSM BACKUP DISK-->TAPELIB "
echo "# "
echo "#####################################################################################"
[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18921899/viewspace-1016980/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/18921899/viewspace-1016980/