ファイルをバックアップしてFTPサーバーにアップロードするbatコード
@echo off
color 0f
title FTP
rem
echo:
set /p bak_webFile= ( ) =
rem ( YYYYMMDD)
set bak_date=%date:~0,4%%date:~5,2%%date:~8,2%
rem ftp
set bak_ftpServer=202.96.189.52
set bak_ftpUserName=Wingl83
set bak_ftpUserPass=l7l2O6OO
echo:
echo:
echo:
rem ftp
echo open %bak_ftpServer% >ftp.up
echo %bak_ftpUserName%>>ftp.up
echo %bak_ftpUserPass%>>ftp.up
echo bin >>ftp.up
echo mput %bak_webFile%\* >>ftp.up
echo bye >>ftp.up
FTP -s:ftp.up -i >>%bak_logPath%log-%bak_date%.txt
del ftp.up /q
del log-%bak_date%.txt /q
echo:
echo:
echo:
ファイルを定期的にバックアップし、FTPをバックアップサーバにアップロードする
rem FTP
rem
set bak_webFile=F:\ \
rem
set bak_tmpFile=C:\~UpTemp\
rem
set bak_logPath=C:\~bak_log\
rem rar
set bak_bakFile=YYYYMMDD( )
rem ( YYYYMMDD)
set bak_date=%date:~0,4%%date:~5,2%%date:~8,2%
rem ftp
set bak_ftpServer=202.96.189.52
set bak_ftpUserName=Wingl83
set bak_ftpUserPass=l7l2O6OO
set bak_timeStart=%time%
md %bak_tmpFile%
md %bak_logPath%
echo -------- [%bak_timeStart%] >%bak_logPath%log-%bak_date%.txt
"C:\Program Files\WinRAR\Rar.exe" a -ag+%bak_bakFile% %bak_tmpFile% %bak_webFile%
echo -------- , [%time%/%bak_timeStart%] >>%bak_logPath%log-%bak_date%.txt
rem ftp
echo open %bak_ftpServer% >ftp.up
echo %bak_ftpUserName%>>ftp.up
echo %bak_ftpUserPass%>>ftp.up
echo bin >>ftp.up
echo mkdir %bak_date% >>ftp.up
echo cd %bak_date% >>ftp.up
echo mput %bak_tmpFile%\* >>ftp.up
echo bye >>ftp.up
FTP -s:ftp.up -i >>%bak_logPath%log-%bak_date%.txt
del ftp.up /q
rem Xcopy %bak_tmpFile%* C:\Temp /y
del %bak_tmpFile%*.* /q /s
rd %bak_tmpFile% /q
echo -------- [%time%/%bak_timeStart%] >>%bak_logPath%log-%bak_date%.txt