关闭

Oracle 自动备份

246人阅读 评论(0) 收藏 举报

linux 自动备份脚本

 

#Backup script writen by liyong
#2006.05.22
#version 1.2
#!/bin/sh
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=orcl
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin

#Set variable for this script.
dateStr=`/bin/date +%Y%m%d`
dmpFileName=$dateStr'_svm.dmp'
dmpLogName=$dateStr'_svm.log'
dmpLocation='/oracle/backup/svm/'$dmpFileName
logLocation='/oracle/backup/log/'$dmpLogName

#Begin to dump.
echo $(date +"%y-%m-%d %H:%M:%S") >>$logLocation
echo "----------Begin to dump wap's data.-----------" >>$logLocation
exp svm/svm owner=username file=$dmpLocation log=$logLocation rows=y FEEDBACK=100000 buffer=100000000
gzip $dmpLocation
rm -rf $dmpLocation
echo "----------End to dump wap's data.-----------" >>$logLocation
echo $(date +"%y-%m-%d %H:%M:%S") >>$logLocation

 

用oracle 用户加入定时执行crontab -e

30 1 * * 6 /oracle/backup/backup.sh
50 2 * * * find /oracle/backup/svm  -type f -mtime +30 -exec rm -f {} /;
50 2 * * * find /oracle/backup/log  -type f -mtime +30 -exec rm -f {} /;

 

 

 

 

 

 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:4591次
    • 积分:109
    • 等级:
    • 排名:千里之外
    • 原创:6篇
    • 转载:3篇
    • 译文:0篇
    • 评论:0条