windows tomcat项目更新及数据库备份脚本

本人使用的是批处理,即用cmd执行的,如果用powershell执行可能会有问题

我的是安装版的tomcat,tomcat已安装成服务


自动更新项目并部署,删除本月之前的备份数据

rem *******************************Code Start*****************************
@echo off

set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
cp "D:\Apache Software Foundation\Tomcat 7.0\webapps\cloudolp.dc.war" D:\backup\cloudolp.dc\%Ymd%.war
cd "D:\project\Cloudolp.dc"
git pull
grails war
net stop Tomcat7

rmdir /s/q "D:\Apache Software Foundation\Tomcat 7.0\webapps\cloudolp.dc"

net start Tomcat7
set "firstDate=%date:~,4%/%date:~5,2%/01"
forfiles /P D:\backup\cloudolp.dc /D  -%firstDate% /C "cmd /c del /f @path"
@echo on 
rem *******************************Code End*****************************

备份数据库,删除本月之前的备份数据

rem *******************************Code Start*****************************
@echo off

set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
mysqldump --opt -u root --default-character-set=utf8 --password=xxoo datacenter > D:\backup\datacenter\%Ymd%.sql
set "firstDate=%date:~,4%/%date:~5,2%/01"
forfiles /P D:\backup\datacenter /D  -%firstDate% /C "cmd /c del /f @path"
@echo on
rem *******************************Code End*****************************



你可能感兴趣的:(JAVA)