WEB开发网
开发学院数据库Oracle 采用oracle中exp远程备份oracle 阅读

采用oracle中exp远程备份oracle

 2012-06-11 20:18:03 来源:WEB开发网   
核心提示: 首先建立备份日期,备份目录,采用oracle中exp远程备份oracle,再次使用oracle的exp命令就行备份,备份的list存在里脚本的当前目录下,可以将该脚本放到crontab列表里,根据数据库的不同建立不同的list即可,备份完成后会通过ssh远程scp到固定机器上,备份成功和失败都会发邮件提醒用户

 首先建立备份日期,备份目录,再次使用oracle的exp命令就行备份,备份的list存在里脚本的当前目录下。备份完成后会通过ssh远程scp到固定机器上。备份成功和失败都会发邮件提醒用户。可以将该脚本放到crontab列表里。根据数据库的不同建立不同的list即可。

oracle中exp备份脚本

#!/bin/bash
#function: to execute the oracle built-in  cmd
#version 1
echo "please run this script on cautiously!!!If you forget sth ,or want to abort the script,now ctrl+c will be abort,if you run it bg,you must now how to abort it."
sleep 10;
echo "now begining"
backupdate=`date +%Y%m%d`
mkdir -p $backupdate
if [[ -d $backupdate ]]&& [[ -f /home/oracle/db_list ]]
then
cd $backupdate
cp /home/oracle/db_list .
else
exit
fi
echo "begining exporting....."
#for db_name in db_list
for db_name in `cat db_list`
do
exp $db_name/123 OWNER=$db_name FILE=$backupdate$db_name.emp

if [ $? -eq 0 ]
        then
        echo "you succeed backup the database"
else
#or >
        echo "you failed backup,you must rerun the script. backup failed"|tee -a error.message
                mail -s 16_oracle_bak [email protected]<error.message
        exit 12
fi
done
#use scp with no password,you must use ssh-key to generate the key
scp -pv /home/oracle/$backupdate/*.emp [email protected]:/data/16_ora_backup/
echo -e "backup finished in $backupdate ." >finished.message
mail -s 16_oracle_bak [email protected]<finished.message

exit 0

Tags:采用 oracle exp

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接