#!/bin/bash
export NLS_LANG=American_America.ZHS16GBK
export BAKUPTIME=`date +%Y%m%d`
export DATA_DIR=/home/oracle/backup/datas/$BAKUPTIME
export TAR_DIR=/home/oracle/backup/tars/$BAKUPTIME
mkdir -p $DATA_DIR
mkdir -p $TAR_DIR
cd $DATA_DIR
echo "Starting bakup..."
echo "Bakup file path $DATA_DIR/earth_$BAKUPTIME.dmp"
exp xxx/xxx file=$DATA_DIR/earth_$BAKUPTIME.dmp log=$DATA_DIR/EARTH_$BAKUPTIME.log
echo "Starting tar..."
echo "Tar file path $TAR_DIR/earth_$BAKUPTIME.tar.gz"
tar -zcvf $TAR_DIR/earth_$BAKUPTIME.tar.gz earth*
echo "Bakup file path $DATA_DIR/DS_$BAKUPTIME.dmp"
exp
xxx/xxx file=$DATA_DIR/DS_$BAKUPTIME.dmp log=$DATA_DIR/DS_$BAKUPTIME.log
echo "Starting tar..."
echo "Tar file path $TAR_DIR/DS_$BAKUPTIME.tar.gz"
tar -zcvf $TAR_DIR/DS_$BAKUPTIME.tar.gz DS*
echo "Bakup completed."
exp
xxx/xxx file=$DATA_DIR/CZWDWI_$BAKUPTIME.dmp rows=n log=$DATA_DIR/CZWDWI_$BAKUPTIME.log
echo "Starting tar..."
echo "Tar file path $TAR_DIR/CZWDWI_$BAKUPTIME.tar.gz"
tar -zcvf $TAR_DIR/CZWDWI_$BAKUPTIME.tar.gz CZWDWI*
echo "Bakup completed."
RemoveDir=/home/oracle/backup/datas
dt=`date +%Y%m%d -d "7 day ago"`
for subdir in `ls $RemoveDir`;
do
if [ "${subdir}" \< "${dt}" ];
then
rm -rf $RemoveDir/$subdir >/dev/null
echo "The directory $RemoveDir/$subdir has been removed."
fi
done
RemoveDir=/home/oracle/backup/tars
dt=`date +%Y%m%d -d "7 day ago"`
for subdir in `ls $RemoveDir`;
do
if [ "${subdir}" \< "${dt}" ];
then
rm -rf $RemoveDir/$subdir >/dev/null
echo "The directory $RemoveDir/$subdir has been removed."
fi
done
阅读(1805) | 评论(0) | 转发(0) |