分类: LINUX
2007-10-25 13:47:59
关于oracle数据备份并自动上传的脚本
这个脚本的效果是让服务器自动按用户名备份oracle服务器的数据并自动上传到FTP服务器上。添加定时任备让每月执行一次。
cat oracle_bak.sh
#!/bin/bash
#set PATH
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/oracle/backup
export PATH
#This is bakup oracle
DATE=`date +%Y-%m-%d`
cd /home/oracle/backup
exp system/*** owner=wapmail file=wapmail"$DATE".dmp
exp system/*** owner=smsuser file=smsuser"$DATE".dmp
exp system/*** owner=wlmnpuser file=wlmnpuser"$DATE".dmp
exp system/*** owner=wlucpuser file=wlucpuser"$DATE".dmp
tar -zcvf hnoracle_bak"$DATE".tar.gz *.dmp
rm -rf *.dmp
####################ftp backup#####
ftp -n 203.*.*.* >>/home/oracle/backup/log.txt <user 用户名 密码
bin
cd hnoracle
put hnoracle_bak"$DATE".tar.gz
bye
!
rm -rf hnoracle_bak"$DATE".tar.gz
echo "oracle backup is $DATE succes"
并加入定时任务
crontab -u oracle -l
#by add chenwenming
30 01 15 * * /home/oracle/oracle_bak.sh >> /home/oracle/backup/ora_bak.txt