#chkconfig:2345 81 05
#description:backup cctiw database
#backup database
cd /home/db2inst2/dbscript
rm -df *.log
echo "BACKUP DATABASE... "`date` >> backup.log
db_name=THPDB
day_keep=7
file_path="/home/db2inst2/"
begin_filename=$db_name".0.db2inst2.NODE0000.CATN0000."
end_filename="`date +%Y%m%d --date=$day_keep' days ago'`"
filename=$begin_filename$end_filename"*"
find $file_path -name $begin_filename"*" >> find.log
row_num=`wc find.log -l`
echo "========BACKUP FILE========" >> backup.log
echo "========LINE NUM OF find.log : "$row_num >> backup.log
echo $result >> backup.log
echo $mat >> backup.log
then
echo "========Because backup failed, save FILE NAME is "$filename >> backup.log
else
echo "========DELETE FILE NAME is "$filename >> backup.log
rm -df $file_path$filename
fi