Scheduled backup implementation under Windows

  

backup.bat file

rem backup database echo start backup database at : %date% %time% >> backup.log (Note: can be under DOS Use echo %date% %time% to view the date format) del E:\\bak\\xx%date:~0,4%%date:~5,2%%date:~8,2%.sqlmysqldump -uroot -proot - c --extended-insert --default-character-set=GB2312 -B xx> E:\\bak\\xx%date:~0,4%%date:~5,2%%date:~8,2%. Sqlecho end backup database at : %date% %time% >> backup.log

rem backup program echo start backup program at : %date% %time% >> backup.lognet stop tomcat > ;> backup.logdel E:\\bak\\xx_program%date:~0,4%%date:~5,2%%date:~8,2%.rarC:\\progra~1\\winrar\\winrar.exe a -r E:\\bak\\dxoa_program%date:~0,4%%date:~5,2%%date:~8,2%.rar D:\\tomcat5\\webapps\\xx\\ >> backup.logcopy Jchatbox.ser D:\\tomcat5\\webapps\\jchat\\WEB-INF\\conf\\jchatbox.ser /y >> backup.lognet start tomcat >> backup.logecho end backup program at : %date% %time% >> backup.log


Get the day of the previous 7 days

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=%%ifor /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\\tmp.vbs') do set m=%%jfor /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\\tmp.vbs' ) do set d=%%kif %m% LSS 9 set m=0%m%if %d% LSS 9 set d=0%d%set deldate=%y%%m%%d%

rem delete 7 days ago data backup echo start del E:\\bak\\xx%deldate%.sql at : %date% %time% >> backup.logdel E:\\bak\\xx%deldate%.sql > > backup.logecho end del E:\\bak\\xx%deldate%.sql at : %date% %time% >> backup.log

rem Delete 7 days ago program backup echo start del E :\\bak\\xx_program%deldate%.rar at : %date% %time% >> backup.logdel E:\\bak\\xx_program%deldate%.rar >> backup.logecho end del E:\\bak\\ Xx_program%deldate%.rar at : %date% %time% >> backup.log
zh-CN"],null,[0.93841946],zh-CN"]]]

Copyright © Windows knowledge All Rights Reserved