mercoledì 27 gennaio 2010

Deploy scripts: DOS batch file [ENG]

From time to time I need to deploy a new web application to a server. There are many ways to do so, but I found this small Windows batch script mighty useful.
  1. stops the application server service
  2. copies the files from the directory ./latest to the proper destination directory
  3. starts the application server service again
  4. renames the directory ./latest with the current date and time (in case you have to rollback)
@echo off
echo Stopping "service x"...
sc \\localhost stop "service x"
echo Deploying files...
xcopy ".\latest\*.*" "destination_dir" /Y /S
echo Restarting "service x"...
sc \\localhost start "schd service"
set Filename=%Date:~-4,4%%Date:~-7,2%%Date:~-10,2%_%Time:~0,2%%Time:~3,2%_application_name
echo Renaming "latest" folder to "%Filename%"...
rename latest %Filename%
pause

Nessun commento: