Chinaunix首页 | 论坛 | 博客
  • 博客访问: 548594
  • 博文数量: 65
  • 博客积分: 1158
  • 博客等级: 少尉
  • 技术积分: 1261
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-18 22:07
文章分类

全部博文(65)

文章存档

2016年(1)

2014年(2)

2013年(9)

2012年(53)

分类: LINUX

2016-01-13 14:30:38

#!/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) |
给主人留下些什么吧!~~