How-To Backup Deployment Folder Before Publish Web Site


  • I use Public Web Site function in Visual Studio 2008 to publish the latest version of my project.

    This is what I currently do:

    1. Publish the web site to a temporary folder.
    2. Backup production web site.
    3. Copy project from temporary folder to production web site.

    I would like to publish the new project directly to the production folder with a pre-step that automatically copies the production web site to a backup folder (time stamped or something) before publishing the new project, like this.

    1. Perform "Publish Web Site".
    2. Before VS.NET executes Publish Web Site, it backs up production web site to backup folder.
    3. After backup, VS.NET continues to publish new project to production web site.

    I was investigating whether custom MSBuild options were available, but wasn't sure if that was a good way to go. Any insight into the best way to do publishes directly to production (after I've performed testing of course) that will incorporate backups before hand, would be greatly appreciated!

    P.S. - Sorry for publishing this to this forum, but I couldn't find any better places to put it.

    Nathon Dalton .NET Software Developer
    • Moved by Hongye Sun - MSFTModerator Thursday, November 26, 2009 4:00 AM This issue is most relative to msbuild. (From:Visual Studio Debugger)
    Wednesday, November 25, 2009 7:21 PM


All replies

  • Hi Nathon,

    Thanks for asking question here. However, this is a ASP.NET deployment issue, while this forum is for Visual Studio Debugger.

    I will move this issue to MSBuild forum, which is most relative to your question in MSDN forums. You can either ask this question to ASP.NET Deployment forum.

    One option for you is to write copy command to backup the production web site at the post-build event of your web site project. The post-build event will be executed between website build and publish. This seems to meet your need.

    Please let me know if this is not an option for you and why. Thanks.


    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, November 26, 2009 3:59 AM
  • You should look to have MSDeploy to do the backup. Then from MSBuild just call msdeploy.exe to do that backup before your deployment.

    My Book: Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build
    My Blog:
    Visual C# MVP
    Monday, November 30, 2009 5:51 PM
  • Thanks everyone! It looks like I have some reading to do! I inherited many of these projects and they were not setup with ease of deployment in mind, so I'm looking at streamlining much of it. Any resources on this as well would be appreciated! Of course free products to do this would be preferred. :) Thanks!
    Nathon Dalton .NET Software Developer
    Wednesday, December 02, 2009 9:01 PM