Updated-Backup Strategies with Web Deploy

Before running the Web Deploy commands to update a web site, make sure to create a backup of the target web files in case a rollback of the operation is required. The process to make a backup on the target server is quick and I would recommend adding these steps to any scripts used for deployments on an IIS server.

These scripts are run from the source server (10.0.0.11) and backing up the files on the target server (10.0.0.12) and the packages are stored on the target server in the c:\_WebDeploy folder.

Web Site Settings Backup:

The first example uses the AppCmd utility to backup the IIS settings. If a server level or web site level deployment has modifications to the IIS settings, make a backup copy of the target IIS settings to quickly restore the server if there are issues with the deployment. Again, this is for IIS settings only.

for /f "skip=1" %%x in ('wmic OS GET LocalDateTime') do if not defined LocalDateTime set LocalDateTime=%%x
set DATESTAMP=%LocalDateTime:~0,8%
set TIMESTAMP=%TIME:~0,2%_%TIME:~3,2%
set TIMESTAMP=%TIMESTAMP: =0%
set FolderDate=%DATESTAMP%_%TIMESTAMP%

REM #This will create a backup of the remote Production site onto the local workstation
msdeploy -verb:sync -source:iisapp="Default Web Site/StructuralInventory",computername=x.x.x.x,username=xxx,password=xxx -dest:package=%Folder%\ProductionWebSite_%MyDate%.zip