Automatically back up and upload to FTP under Window

  
 1. The new health backup.bat

rem file backup program to back up the project
echo start time:% date%% time% & gt; & gt; backup.log
rem closed tomcat start /wait call representation to wait and then run to completion and exit shutdown.bat to run
start /wait call d: \\ backup \\ bat \\ tomcat6 \\ shutdown.bat & gt; & gt; backup.log

del d: \\ backup \\bak\\portal_cas_%date:~0,4%%date:~5,2%%date:~8,2%.rar
rem Compression project file
C:\\progra~1\\winrar\\winrar .exe ad:\\backup\\bak\\portal_cas_%date:~0,4%%date:~5,2%%date:~8,2%.rar D:\\tomcat-6.0.20\\webapps >> backup.log

echo end of the project backup:% date%% time% & gt; & gt; backup.log



rem get 7 days before the date

echo wscript.echo dateadd("d",-7,date) >%tmp%\\tmp.vbs
for /f "tokens=1,2,3 delims=/- " % %i in ('cscript /nologo %tmp%\\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3 delims=/- " %%i in ( 'cscript /nologo %tmp%\\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nolo Go %tmp%\\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set deldate =% y %% m %% d%


rem delete 7 days before the backup program
echo start del d: \\ backup \\ bak \\ portal_cas_% deldate% .rar at : %date% %time% >> backup.log
del d:\\backup\\bak\\portal_cas_%deldate%.rar >> backup.log
echo end del d:\\backup\\bak \\ portal_cas_% deldate% .rar at:% date%% time% & gt; & gt; backup.log

rem build a temporary connection ftp script, because it can now, according to the current time we want to generate scripts to meet the current upload Time-named file
echo open 59.208.8.4 >> ftp.tmp
echo user ycoa bester@2010 >> ftp.tmp
echo cd server5 >> ftp.tmp
echo bin >> ftp.tmp
echo prompt off >> ftp.tmp
echo send d:\\backup\\bak\\portal_cas_%date:~0,4%%date:~5, 2%%date:~8,2%.rar >> ftp.tmp
echo del portal_cas_%deldate%.rar >> ftp.tmp
echo bye >> ftp.tmp< Br>
rem Start using ftp client connection and execute ftp temporary script
ftp -n -s: ftp.tmp

rem delete temporary files ftp
del /f ftp.tmp


rem start tomcat start Tomcat
call d: \\ backup \\ bat \\ tomcat6 \\ startup.bat & gt; & gt; backup.log

2. Add tasks and set task time when scheduling tasks. If you have a password,




If you have a password, it may be reported that the process is using errors for some reason. You can add a task first to let the server automatically restart or log off
and then perform the backup task

Copyright © Windows knowledge All Rights Reserved