#!/bin/sh  
export ORACLE_BASE=/opt/oracle  
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1  
export ORACLE_SID=orcl  
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin  
  
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8  
  
export DATA_DIR=/opt/backup/data  
export LOGS_DIR=/opt/backup/logs  
export DELTIME=`date -d "7 days ago" +%Y%m%d`  
export BAKUPTIME=`date +%Y%m%d%H%M%S`  
  
mkdir -p $DATA_DIR  
mkdir -p $LOGS_DIR  
echo "Starting bakup..."  
echo "Bakup file path $DATA_DIR/$BAKUPTIME.dmp"  
exp anda
cms/andacms@orcl file=$DATA_DIR/$BAKUPTIME.dmp log=$LOGS_DIR/$BAKUPTIME.log  
  
echo "Delete the file bakup before 7 days..."    
rm -rf $DATA_DIR/$DELTIME*.dmp  
rm -rf $LOGS_DIR/$DELTIME*.log  
echo "Delete the file bakup successfully. "    
    
echo "Bakup completed."