情况:  现在OAS下面有很多 OC4J, 每个 OC4J 都有自己的配置文件, 所以想定时备份 指定的文件到指定的目录,因为备份目录浪费太大的空间了。

 

#! /bin/bash
oas_home=/opt/oracle/as10g01/j2ee
bak_dir=conf_bak_dir
bakfile=$1
cd $oas_home
if [ $# -lt 1 ]
then
echo "please input file name !!!"
exit
fi
find . -name "$bakfile" > server_conf.list
if [ -d $bak_dir ]
then
echo "bak_dir have already exist!"
else
mkdir $bak_dir
fi
while read line
do
oc4jname=`echo $line|cut -d / -f2`
filename=`echo $line|cut -d / -f4`.bak
subdir=./$bak_dir/$oc4jname
if [ -d $subdir ]
then
echo $subdir has already exist!
else
mkdir $subdir
fi
cp $line ./$bak_dir/$oc4jname/$filename
done <server_conf.list