One of the most essential steps in managing web application updates is the ability to recover to a point in time prior to the update should the deployment of updates be unsuccessful. MSDeploy simplifies this step and can even be incorporated into build definitions to create automated backups when a deployment build is executed.
To create a backup of a site from an existing site simply execute the following command:
msdeploy -verb:sync -source:iisapp=”Default Web Site” -dest:package=c:\defaultsite.zip
This will create a deployment package of the iis application running as “Default Web Site” on the machine where the msdeploy command was executed. If you want to remotely administer a web server ensure Web Deploy 2.0 is installed on the target machine and modify the command as follows:
msdeploy -verb:sync -source:iisapp=”Default Web Site”,computername=MyServer -dest:package=c:\defaultsite.zip
You must have administrative privileges on the server you are trying to sync from in order for this command to be successful.
Restoring the backup is as simple as running the command below:
msdeploy -verb:sync -source:package=c:\defaultsite.zip -dest:iisapp=”Default Web Site”,computername=MyServer
Again, you will need administrative privileges on the target server for this command to succeed.