Aix 5.3下自动备份Oracle多个实例[原创]

#Oracle environment variables defined
#(在下面写上,此处隐藏)

 

#Database User Information
USERNAME=数据库用户名(信息隐藏)
PASSWORD=数据库密码(信息隐藏)

 

#Back file
FILE_PREFIX=Oracle_

 

#FTP Server Information
FTP_SERV=FTP服务器(信息隐藏)
FTP_USER=FTP用户名(信息隐藏)
FTP_PASS=FTP密码(信息隐藏)
FTP_DIR=FTP目录(信息隐藏)
FTP_DIR2=FTP目录(信息隐藏)

 

#Back directory
BACKUP_DIR=/opt/databack/App

 

#Date Format
DATE=`date +%Y%m%d`

 

#Oracle instance
EXP1=第一个ORACLE实例名称(信息隐藏)
EXP2=第二个ORACLE实例名称(信息隐藏)
EXP3=第三个ORACLE实例名称(信息隐藏)

 

#Go to the backup directory
cd ${BACKUP_DIR}

 

#The first instance of the backup
export ORACLE_SID=${EXP1}
if [ -f ${EXP1}_${DATE}.dmp ]; then
    echo exp ${EXP1} `date +%Y-%m-%d` backup file already exists.
else
    exp ${USERNAME}/${PASSWORD} file=${EXP1}_${DATE}.dmp
fi

 

#The second instance of the backup
export ORACLE_SID=${EXP2}
if [ -f ${EXP2}_${DATE}.dmp ]; then
    echo exp ${EXP2} `date +%Y-%m-%d` backup file already exists.
else
    exp ${USERNAME}/${PASSWORD} file=${EXP2}_${DATE}.dmp
fi

 

#The third instance of the backup
export ORACLE_SID=${EXP3}
if [ -f ${EXP3}_${DATE}.dmp ]; then
    echo exp ${EXP3} `date +%Y-%m-%d` backup file already exists.
else
    exp ${USERNAME}/${PASSWORD} file=${EXP3}_${DATE}.dmp
fi

 

#Compressed backup files
if [ -f ${BACKUP_DIR}/${FILE_PREFIX}${DATE}.tar.gz ]; then
    echo `date +%Y-%m-%d` backup File already exists.
else
    tar -cf ${FILE_PREFIX}${DATE}.tar.gz ${EXP1}_${DATE}.dmp ${EXP2}_${DATE}.dmp ${EXP3}_${DATE}.dmp
fi

 

#Delete backup files
    rm -rf ${EXP1}_${DATE}.dmp ${EXP2}_${DATE}.dmp ${EXP3}_${DATE}.dmp

 

#Upload backup file
ftp -n $FTP_SERV <<AUTO_FTP
user $FTP_USER $FTP_PASS
passive
binary
cd $FTP_DIR
cd $FTP_DIR2
put ${FILE_PREFIX}${DATE}.tar.gz ${FILE_PREFIX}${DATE}.tar.gz
AUTO_FTP


本文来自:韦少乾博客(mven.cn)
详细出处:http://mven.cn/post/34.html

你可能感兴趣的:(html,oracle,F#,AIX,Go)