ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 自动expftp备份

自动expftp备份

原创 Linux操作系统 作者:lsm_3036 时间:2011-04-07 09:56:25 0 删除 编辑
#!/bin/bash
#Program:
#      Autobackup according to different user and ftp data to another machine
# History:
#2010/10/26   Liu Shiming   First release
#1.Start export data
export ORACLE_SID=NACEC
export ORACLE_TERM=xterm
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export NLS_LANG=american_america.UTF8
export LANG=en_US
export time=`date '+%y%m%d'`                                                  
export ORACLE_HOME=/home/DBSoftware/oracle/product/10.2.0/db_1 
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin 
#export nacecweb data
exp userid=nacecweb/tadernacecweb file=/backup/nacecweb$time.dmp wner=nacecweb log=/backup/nacec.log
#export turbocms data
exp userid=turbocms/taderturbocms file=/backup/turbocms$time.dmp wner=turbocms log=/backup/nacec.log
#export nacec data
exp userid=nacec/tadertader file=/backup/nacec$time.dmp wner=nacec log=/backup/nacec.log    
sleep 5s
sync;sync      
#2.Compress all the data
cd /backup
   tar -zpcf backup$time.tar.gz * --exclude backup$time.tar.gz
sleep 5s
sync;sync
#3.Drop dmp files before let the log file can't be droped
cd /backup
rm -f *.dmp
rm -f *.log
sleep 5s
sync;sync
#4.Ftp the file to another machine
id="ftpadmin"
pw='ftpadmin'
ftp -n << EOF
  open 192.168.188.58
  user $id   $pw
  bin
  lcd /backup
  cd /backup
  put backup$time.tar.gz
bye
EOF
sync;sync
#注意:
#1.两台机器必须都开vsftpd服务
#2.要使用oracle的用户去执行这个脚本
#3.在例行性命令的使用中,也要使用oracle用户去执行;vi /etc/crontab里面写入00 18 * * * oracle /backup/backuplogic.sh

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16978544/viewspace-691836/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-12-08

  • 博文量
    64
  • 访问量
    138415