@echo off
rem 指定FTP用户名
set ftpUser=***
rem 指定FTP密码
set ftpPass=******
rem 指定FTP服务器地址
set ftpIP=*.*.*.*
rem 1.数据库------------------服务器
set ftpFolder=mysqlbak
rem 2.工程日志----------服务器
set ftpFolder2=webapp/ROOT/logs
rem 3.还款计划----------------服务器
set ftpFolder3=repaymentPlan
rem 4.程序包------------------服务器
set ftpFolder4=webbak
rem 1.数据库------------------本地 0
set LocalFolder=e:\aliyunbak\dbbackup
rem 2.玖和宝工程日志----------本地 1
set LocalFolder2=e:\aliyunbak\jiuhebaologs
rem 3.还款计划----------------本地 0
set LocalFolder3=e:\aliyunbak\repaymentPlan
rem 4.程序包------------------本地 1
set LocalFolder4=e:\aliyunbak\webbak
rem 假设本机日期格式为yyyy-mm-dd(今天下载文件20090714.txt)
set DownDaysAgo=0
set DownDaysAgo2=1
rem 假设系统日期的格式为yyyy-mm-dd
call ateToDays %date:~0,4% %date:~5,2% %date:~8,2% DownPassDays
set /a DownPassDays-=%DownDaysAgo%
set /a DownPassDays2=DownPassDays-%DownDaysAgo2%
call :DaysToDate %DownPassDays% DstYear DstMonth DstDay
call :DaysToDate %DownPassDays2% DstYear3 DstMonth3 DstDay3
set DownDstDate=%DstYear%-%DstMonth%-%DstDay%
set DownDstDate2=%DstYear%%DstMonth%%DstDay%
set DownDstDate3=%DstYear3%-%DstMonth3%-%DstDay3%
set DownDstFile=jhddb%DownDstDate%.sql.gz
set DownDstFile2=jhd.log.%DownDstDate3%
set DownDstFile3=repayment%DownDstDate2%.xls
set DownDstFile4=%DownDstDate3%.tar.gz
echo %DownDaysAgo%天前的日期是%DownDstDate%
set DelDaysAgo=30
rem 假设系统日期的格式为yyyy-mm-dd
call :DateToDays %date:~0,4% %date:~5,2% %date:~8,2% DelPassDays
set /a DelPassDays-=%DelDaysAgo%
call :DaysToDate %DelPassDays% DstYear DstMonth DstDay
set DelDstDate=%DstYear%-%DstMonth%-%DstDay%
set DelDstDate2=%DstYear%%DstMonth%%DstDay%
set DelDstFile=jhddb%DelDstDate%.sql.gz
set DelDstFile2=jhd.log.%DelDstDate%
set DelDstFile3=repayment%DelDstDate2%.xls
set DelDstFile4=%DelDstDate2%.tar.gz
echo %DelDaysAgo%天前的日期是%DelDstDate%
set ftpFile=%temp%\TempFTP.txt
>"%ftpFile%" (
echo %ftpUser%
echo %ftpPass%
echo cd "%ftpFolder%"
echo bin
echo mget "%DownDstFile%"
echo mdelete "%DelDstFile%"
echo bye
)
set ftpFile2=%temp%\TempFTP2.txt
>"%ftpFile2%" (
echo %ftpUser%
echo %ftpPass%
echo cd "%ftpFolder2%"
echo bin
echo mget "%DownDstFile2%"
echo mdelete "%DelDstFile2%"
echo bye
)
set ftpFile3=%temp%\TempFTP3.txt
>"%ftpFile3%" (
echo %ftpUser%
echo %ftpPass%
echo cd "%ftpFolder3%"
echo ascii
echo mget "%DownDstFile3%"
echo mdelete "%DelDstFile3%"
echo bye
)
set ftpFile4=%temp%\TempFTP4.txt
>"%ftpFile4%" (
echo %ftpUser%
echo %ftpPass%
echo cd "%ftpFolder4%"
echo bin
echo mget "%DownDstFile4%"
echo mdelete "%DelDstFile4%"
echo bye
)
cd /d "%LocalFolder%"
ftp -v -i -s:"%ftpFile%" %ftpIP%
cd /d "%LocalFolder2%"
ftp -v -i -s:"%ftpFile2%" %ftpIP%
cd /d "%LocalFolder3%"
ftp -v -i -s:"%ftpFile3%" %ftpIP%
cd /d "%LocalFolder4%"
ftp -v -i -s:"%ftpFile4%" %ftpIP%
:DateToDays %yy% %mm% %dd% days
setlocal ENABLEEXTENSIONS
set yy=%1&set mm=%2&set dd=%3
if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
endlocal&set %4=%j%&goto :EOF
:DaysToDate %days% yy mm dd
setlocal ENABLEEXTENSIONS
set /a a=%1+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
endlocal&set %2=%yy%&set %3=%mm%&set %4=%dd%&goto :EOF作者: bkxmgx 时间: 2015-7-30 11:15