######################################################################## # # Kfc_incremental_hot_database_ backup.sh # # # Created by NBU TEMP # # # 2012-3-8 # # ############
############################################################# #!/bin/ksh export Lang=en_us BACKUP_DATE= ' DATE +%d ' Rman_log_file=/home/oracle/1028/log/backupinfo.out today= ' date ' user= ' id|cut-d ' ("-f2|cut-d") "-f1 ' echo"---------- -------$TODAY-------------------"> $RMAN _log_file oracle_home=/u01/app/oracle/product/11.2.0/db_1 export ORACLE _home rman= $ORACLE _home/bin/rman export RMAN ORACLE_SID=ORCL export oracle_sid oracle_user=oracle export Oracle_user E Cho "Oracle_sid: $ORACLE _sid" >> $RMAN _log_file echo "Oracle_home: $ORACLE _home" >> $RMAN _log_file echo " Oracle_user: $ORACLE _user ">> $RMAN _log_file echo" ========================================== ">> $RMAN _ Log_file echo "BACKUP DATABASE BEGIN ..." >> $RMAN _log_file echo " ">> $RMAN _log_file #touch $RMAN _log_file chmod 666 $RMAN _log_file week_daily= ' date +%a ' case" $WEE
K_daily "in" Mon ") bak_level=1;
"Tue") bak_level=1;;
"Wed") bak_level=1;;
"Thu") bak_level=1;;
"Fri") bak_level=1;;
"Sat") bak_level=0;;
"Sun") bak_level=1; "*") bak_level=error ESAC export bak_level= $BAK _level echo "Today is: $WEEK _daily incremental Level= $BAK _ Level >> $RMAN _log_file run_str= bak_level= $BAK _level export bak_level oracle_home= $ORACLE _home export Oracle_h
OME oracle_sid= $ORACLE _sid export oracle_sid $RMAN nocatalog TARGET sys/oracle msglog $RMAN _log_file Append <<eof
Run {Allocate channel C1 type disk;
Allocate channel C2 type disk; Backup incremental level= $BAK _level Skip InacCessible filesperset 5 Database format= '/home/oracle/1028/backup/orcl_lev "$BAK _level" _%u_%t ' tag= ' Orcl_lev "$BAK _
Level "';
SQL ' alter system archive log current '; Backup Archivelog all tag= ' Arc_bak ' format= '/home/oracle/1028/backup/arch_%u_%t ' skip inaccessible Filesperset 5 not BAC
ked up 1 times Delete input;
Backup current Controlfile tag= ' bak_ctlfile ' format= '/home/oracle/1028/backup/ctl_file_%u_%t ';
Backup SPFile tag= ' spfile ' format= '/home/oracle/1028/backup/orcl_spfile_%u_%t ';
Release channel C2;
Release channel C1;
} report obsolete;
Delete NoPrompt obsolete;
Crosscheck backup;
Delete noprompt expired backup;
List Backup summary; EOF "# Initiate the command string if [" $CUSER "=" root "] then echo" root command string: $RUN _str ">> $RMA
N_log_file su-$ORACLE _user-c "$RUN _str" >> $RMAN _log_file rstat=$?
else echo "User Command String: $RUN _str" >> $RMAN _log_file/bin/sh-c "$RUN _str" >> $RMAN _log_file Rstat=$?
Fi #---------------------------------------------------------------------------# Log The completion of this script. #---------------------------------------------------------------------------If ["$RSTAT" = "0"] then logmsg= "Ende D successfully "Else logmsg=" ended in error "fi echo >> $RMAN _log_file echo Script $ >> $RMAN _log_file E Cho = = $LOGMSG on ' date ' = = >> $RMAN _log_file echo >> $RMAN _log_file exit $RSTAT
Note: Change the creation directory according to the actual situation, the date of full and incremental backup is set as required