脚本功能:定时备份oracle数据库,上传到指定服务器,删除时间超过14天的备份文件。
#=========================================================================
# Purpose:exp Oracle DB orcl to file orcl_YYYYMMDDHHMM.dmp,
# and Delete the file,30 days ago created
# Author :2013-05-31
# History:
# Note :erveryday excute this script at 02:00,set root cron to
# 0 2 * * * su - oracle -c /orabak/autobak/orabak.sh
#=========================================================================
#!/bin/sh
#ftp info
host=10.1.244.59
port=21
Username=ftpuser
Passwd=ftp123
des_bakup_path=/backup
#set saved backup path
backup_path=/orabak/dmp
echo start backup
DATETIME=`date +'%Y%m%d%H%M'` #get today date ,eg 20120820
export DATETIME
exp releaseusr/passw0rd file=/orabak/dmp/releaseusr_$DATETIME.dmp log=/orabak/dmp/releaseusr$DATETIME.log
exp communityusr/passw0rd file=/orabak/dmp/communityusr_$DATETIME.dmp log=/orabak/dmp/communityusr$DATETIME.log
exp customizationusr/passw0rd file=/orabak/dmp/customizationusr_$DATETIME.dmp log=/orabak/dmp/customizationusr$DATETIME.log
exp jcr/passw0rd file=/orabak/dmp/jcr_$DATETIME.dmp log=/orabak/dmp/jcr$DATETIME.log
exp feedback/passw0rd file=/orabak/dmp/feedback_$DATETIME.dmp log=/orabak/dmp/feedback$DATETIME.log
exp lmdbusr/passw0rd file=/orabak/dmp/lmdbusr_$DATETIME.dmp log=/orabak/dmp/lmdbusr$DATETIME.log
exp icms/passw0rd file=/orabak/dmp/icms_$DATETIME.dmp log=/orabak/dmp/icms$DATETIME.log
#--- zip the back dmp file, by
gzip /orabak/dmp/*.dmp
#--- ftp start
echo automatic ftp start
cd $backup_path
/usr/bin/ftp -n <
open $host $port
user $Username $Passwd
binary
cd $des_bakup_path
put releaseusr_$DATETIME.dmp.gz
put communityusr_$DATETIME.dmp.gz
put customizationusr_$DATETIME.dmp.gz
put jcr_$DATETIME.dmp.gz
put feedback_$DATETIME.dmp.gz
put lmdbusr_$DATETIME.dmp.gz
put icms_$DATETIME.dmp.gz
put releaseusr$DATETIME.log
put communityusr$DATETIME.log
put customizationusr$DATETIME.log
put jcr$DATETIME.log
put feedback$DATETIME.log
put lmdbusr$DATETIME.log
put icms$DATETIME.log
!
echo rm file
#rm file
find /orabak/dmp -type f -mtime +14 -exec rm {} \;
阅读(1494) | 评论(1) | 转发(0) |