#!/bin/bash
FtpServer='10.10.81.136'
FtpUser='user_tt'
FtpPW='User_pw'
TarName=`hostname`_`date +%Y%m%d`.tgz
BackDir='/opt/bin/backup/data/'
SourceDir='/opt/mysql/var'
FtpDir=`date +%Y%m%d`
DelTarName=`hostname`_`date -d '-3 day' +%Y%m%d`.tgz #删除三天前的文件
if [ -f $BackDir$DelTarName ]
then rm -rf $BackDir$DelTarName
fi
/etc/init.d/mysqld stop
tar zcfP $BackDir$TarName $SourceDir
/etc/init.d/mysqld start
ftp -n $FtpServer <user $FtpUser $FtpPW
binary
prompt
lcd $BackDir
mkdir $FtpDir
cd $FtpDir
mput $TarName
bye
Eof
阅读(931) | 评论(0) | 转发(0) |