ftp传输文件到指定服务器

#!/bin/bash

filePrefix="dbname"
localDir="/DBBackup"
remoteDir="/Backup"

cd $localDir

oldfile=$filePrefix"_$(date +%Y%m%d)*.sql"
newfile=$filePrefix"_$(date +%Y%m%d)_sql.tar.gz"


tar -czvf $newfile $oldfile

lftp ftp://BackupUser:'username'@192.168.0.1 <<END
cd $remoteDir
lcd $localDir
mput $newfile
bye
END
rm -rf $filePrefix_*.tar.gz
rm -rf $(find $localDir -ctime +2 -name "$filePrefix_*.sql")

posted on 2015-04-17 08:55  franjia  阅读(607)  评论(0编辑  收藏  举报