Web-development – Best practices for managing deployment of code from dev to production servers

deploymentsource codeweb-development

I am hoping to find an easy tool or method, that allow's managing our code deployment.

Here are the features I hope this solution has:

  1. Either web-based or batch file, that given a list of files, will communicate to our production server, to backup those files in different folders, and zip them and put them in a backup code folder.

  2. Then it records the name, date/time, and purpose of the deployment.

  3. Then it sends the files to their proper spot on the production server.

I don't want too complex an interface to doing the deployment's because then they might never use it.

Or is what I am asking for too unrealistic?

I just know that my self-discipline isn't perfect, and I'd rather have a tool I can rely on to do what needs to be done, then my own memory of what exact steps I have to take every time.

How do you guys, make sure everything get's deployed correctly, and have easy rollback in case of any mistakes?

Best Answer

All this can be done by a batch file. The following are the basic steps need to happen in batch file:

  1. Get current date time in a variable.
  2. Make copies of the production directory into folders with the current date time. Zip the folder if you want.
  3. Replicate the build dropping folder to production directories. You can also skip some files you don't want to overwrite (like web.config). Both xcopy and robocopy allow skipping files.

Except the first step, the other two steps are very basic command line operations. Regarding the first one, the following code shows how to get a directory with date time:

for /f "tokens=1-3 delims=/ " %%A in ("%DATE%") DO (
  set DATESTR=%%C%%A%%B
)

for /f "tokens=1-3 delims=:." %%F in ("%TIME%") DO (
  set TIMESTR=%%F%%G%%H
)

set CURRENTDT=%DATESTR%T%TIMESTR%

:: now you can use the date time in a folder name:
xcopy /e \\production1\site1 \\backup\site1\backup-%CURRENTDT%\
Related Topic