housekeep arch logs (tested on AIX)
#!/usr/bin/ksh
#----------------------------------------------------------------#
# File Name : housekeeparch.ksh #
# Description : This Program will take a snaphot of #
# Archive Log files and remove only those #
# once the backup is completed #
# Version : 1.0 #
# Usage : housekeeparch.ksh
# sid - ORACLE_SID #
# Type - PRE or POST #
# PRE - take snapshot of archive log #
# files #
# POST - Remove the files from the #
# snapshot take in PRE #
# History #
# ======= #
# 17/01/2010 Ramesh Initial Version #
#----------------------------------------------------------------#
ORACLE_BASE=/optware/oracle
MON=`date '+%m%Y'`
Conf=$ORACLE_BASE/dbaconf
OsName=`uname`
case $OsName in
HP-UX) BDF="bdf";;
SunOS) BDF="df -k";;
OSF1) BDF="df -k";;
AIX) BDF="df -k";;
esac
aclfile=$ORACLE_BASE/tmp/housekeeparch.acl
ErrDisp ()
{
echo
echo `date "+%Y-%m-%d %H:%M:%S"` : "${ErrMsg}"
echo `date "+%Y-%m-%d %H:%M:%S"`" : ${Type} Job Terminated"
echo `date "+%Y-%m-%d %H:%M:%S"`" : Exit Status = -1"
echo "#------------------------------- New Adhoc Archive Backup Job End -------------------------------#"
if [ ${LogFile:-0} != 0 ]
then
echo >> ${LogFile}
echo `date "+%Y-%m-%d %H:%M:%S"` : "${ErrMsg}" >> ${LogFile}
echo `date "+%Y-%m-%d %H:%M:%S"`" : ${Type} Job Terminated" >> ${LogFile}
echo `date "+%Y-%m-%d %H:%M:%S"`" : Exit Status = -1" >> ${LogFile}
echo "#------------------------------- New Adhoc Archive Backup Job End -------------------------------#" >> ${LogFile}
echo >> ${LogFile}
fi
exit -1
}
#-------------------------------------
# Main Program Starts Here
#-------------------------------------
OraSid=$1
Type=$2
echo "#------------------------------- New Adhoc Archive Backup Job Begin -----------------------------#"
if [ $# -ne 2 ]
then
ErrMsg="Error. Usage : housekeeparch.ksh "
ErrDisp
fi
if [ "$Type" != "PRE" -a "$Type" != "POST" ]
then
ErrMsg="Error. Usage : housekeeparch.ksh "
ErrDisp
fi
LogFile=${ORACLE_BASE}/admin/${OraSid}/create/arch_files_${OraSid}_${MON}.log
echo `date "+%Y-%m-%d %H:%M:%S"`" : ${Type} Job Started"
echo
echo "Log File : $LogFile"
echo "ORACLE_SID : $OraSid"
echo "Type : $Type"
echo "Config File : $Conf"
echo "#------------------------------- New Adhoc Archive Backup Job Begin -----------------------------#" >> ${LogFile}
echo `date "+%Y-%m-%d %H:%M:%S"`" : ${Type} Job Started" >> ${LogFile}
echo >> ${LogFile}
echo "Log File : $LogFile" >> ${LogFile}
echo "ORACLE_SID : $OraSid" >> ${LogFile}
echo "Type : $Type" >> ${LogFile}
echo "Config File : $Conf" >> ${LogFile}
if [ ! -f ${Conf} ]
then
ErrMsg="Error : Config File Does not Exist."
ErrDisp
fi
ArchDir=`grep ARCHDST ${Conf}|grep ${OraSid}|cut -d: -f3`
echo "Archive Log Directory : $ArchDir"
echo "Archive Log Directory : $ArchDir" >> ${LogFile}
if [ ! -d ${ArchDir} ]
then
ErrMsg="Error. Archive Log Directory Not exist"
ErrDisp
fi
#if [ ! -e $ArchDir/*${OraSid}*arc* ]
#then
# ErrMsg="Error. Archive Log Directory empty"
# ErrDisp
#fi
ArchLogFile=${ArchDir}/arch_files_${OraSid}.log
echo "Archive Files List : $ArchLogFile"
echo "Archive Files List : $ArchLogFile" >> ${LogFile}
if [ " $Type " = " PRE " ]
then
if [ -f "${ArchLogFile}" ]
then
ErrMsg="Archive Log Backup is Running already"
ErrDisp
fi
echo >> ${LogFile}
echo "File System Usage" >> ${LogFile}
echo "-----------------" >> ${LogFile}
$BDF ${ArchDir} >> ${LogFile}
echo >> ${LogFile}
echo "List of Files" >> ${LogFile}
echo "-------------" >> ${LogFile}
ls -lt ${ArchDir}/*.arc* >> ${LogFile}
ls -ltr ${ArchDir}/*.arc*|awk '{print $9}' > ${ArchLogFile}
if [ $? -ne 0 ]
then
ErrMsg="Error in Creating Archive Log List File"
ErrDisp
fi
aclget ${ArchLogFile}|tail -9 > $aclfile
echo " enabled" >>$aclfile
echo "permit r-x u:oracle">>$aclfile
aclput -i $aclfile $ArchLogFile
chmod u-rwx,g-rwx,o-rwx ${ArchLogFile}
fi
if [ " $Type " = " POST " ]
then
if [ ! -f ${ArchLogFile} ]
then
ErrMsg="Error. Pre Image is not available"
ErrDisp
fi
chmod 400 ${ArchLogFile}
echo >> ${LogFile}
echo "List of Files" >> ${LogFile}
echo "-------------" >> ${LogFile}
cat ${ArchLogFile} >> ${LogFile}
echo >> ${LogFile}
for fname in `cat ${ArchLogFile}`
do
rm -f ${fname}*
echo "Removed File ... ${fname}" >> ${LogFile}
done
rm -f ${ArchLogFile}
if [ $? -ne 0 ]
then
echo "Error in Removing Archive Log List File ...exiting"
exit -1
fi
echo
echo >> ${LogFile}
echo "File System Usage" >> ${LogFile}
echo "-----------------" >> ${LogFile}
$BDF ${ArchDir} >> ${LogFile}
fi
echo
echo `date "+%Y-%m-%d %H:%M:%S"`" : ${Type} Job Completed"
echo `date "+%Y-%m-%d %H:%M:%S"`" : Exit Status = 0"
echo "#------------------------------- New Adhoc Archive Backup Job End -------------------------------#"
echo >> ${LogFile}
echo `date "+%Y-%m-%d %H:%M:%S"`" : ${Type} Job Completed" >> ${LogFile}
echo `date "+%Y-%m-%d %H:%M:%S"`" : Exit Status = 0" >> ${LogFile}
echo "#------------------------------- New Adhoc Archive Backup Job End -------------------------------#" >> ${LogFile}
echo >> ${LogFile}
##############################################################3
PWPBASE:/opt/pwp/3.0
ADMPAGE:35
TRFLAGE:15
LGFLAGE:30
ALOGAGE:180
ARCHLMT:75
ORAHLMT:85
CRSHLMT:85
ASMHLMT:85
ASMDLM1:15
ASMDLM2:5
ASMALM1:25
ASMALM2:15
TBLSLMT:15
EXTNMON:1
GRPMAIL:dba@citi.com
ARCHDST:cnccgu:/uccgreg2/uoradata/cnccgu_arch
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8337095/viewspace-1058199/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- TiDB 2.1: Battle-Tested for an Unpredictable WorldTiDBBAT
- [LeetCode] 2960. Count Tested Devices After Test OperationsLeetCodedev
- Play Arch LinuxLinux
- Extents in Materialized Views and Their Logs (18)ZedView
- Materialized View Logs (190)ZedView
- 使用 arch-ppa 建立你自己的 Arch Linux 軟體庫Linux
- ABS - the Arch Build System(轉)UI
- www/wwwroot/storage/logs" and its not b
- How Logs Work On MySQL With InnoDB TablesMySql
- flush logs時做的操作
- 【操作】調整Online Redo Logs大小(Resizing Oracle Online Redo Logs)Oracle
- Arch Linux配置gnome桌面Linux
- Arch! 從安裝開始
- Linux基礎命令---archLinux
- chroot恢復Arch LinuxLinux
- Arch Linux AUR 工具 yayLinux
- Arch更新時failed to prepare transactionAI
- ARCH wait on SENDREQ 等待事件AI事件
- 安裝 Lantern (Arch Linux)Linux
- 等待事件ARCH wait on ATTACH事件AI
- 時間同步(Arch Linux)Linux
- Arch Linux安裝macOSLinuxMac
- Arch Linux ARM相關Linux
- AAPT2 error: check logs for detailsAPTErrorAI
- Purge Old Mongo Logs without User InterventionGo
- Antergos:基於 Arch 發行版,想要嘗試 Arch 的絕對值得一試Go
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_Compile
- ASM Installation Logs Location. [ID 1349705.1]ASM
- Olsnodes Produces CPU Spikes With Many Logs [ID 729349.1]
- Backing Up Logs with BACKUP … PLUS ARCHIVELOGHive
- RMAN-05541: no archived logs found in target databaseHiveDatabase
- Vmware Station安裝Arch LinuxLinux
- Arch Linux 安裝 AnboxLinux
- Arch Linux 系統遷移Linux
- 排版環境搭建(Arch Linux)Linux
- Arch Linux 中文社群倉庫Linux
- wsl2+arch+個人向美化
- SGS授予海信全球首張洗衣機SGS Performance Tested Mark認證證書ORM