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 ( and backing up the files on the target server ( 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.

%windir%\system32\inetsrv\appcmd add backup “PreContoso_v2.1_Deployment”

Web Site Content Backup:

This command will backup all settings for the target IIS server.

Server Level Backup:

#Remote Server

msdeploy -verb:sync -source:webServer,computername= dest:package=c:\IIS_Backups\Contoso_v2.1_Deployment.zip

#Local Server

msdeploy -verb:sync -source:webServer -dest:package=C:\IIS_Backups\IISServerBackup.zip

#Compare Backup to In Production Web Server (Verify backup)

msdeploy –verb:sync –source:package=C:\IIS_Backups\IISServerBackup.zip -dest:webServer -whatif

#Compare 2 Backup Packages:
msdeploy –verb:sync –source:package=C:\IIS_Backups\IISServerBackup.zip -dest:package=C:\IIS_Backups\IISServerBackup_09272017.zip -whatif

Web Site Level Backup:

msdeploy –verb:sync -source:contentPath="Contoso.com",computername= -dest:package=c:\IIS_Backups\Contoso_v2.1_Deployment.zip

The contentPath provider uses the dirPath and filePath providers to function.

Folder Level Backup:

msdeploy –verb:sync –source:dirPath="c:\inetput\websites\contoso\staticfiles",computername= -dest:package=c:\_WebDeploy\Contoso_v2.1_staticfiles.zip

Batch File Script to Automate the Backup of Website

REM: Get the current date and time

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%
rem Create folder
set Folder=c:\web_deploy\Backup\Production_Server\%FolderDate%_Archive
mkdir %Folder%
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
Comments (4)
  1. Gaurav says:

    looks like the verb should be '-verb:sync' instead of '–verb:dump'

  2. Eric Parvin says:

    Yes, the -Sync command can be used as well for each of these commands.

  3. cori says:

    I’d say the limitation is stronger than just that -verb:sync *can* be used. At least with msdeploy 3.6 -verb:dump doesn’t allow the -dest parameter at all.

    With -verb:sync, though, you, you can backup to a local package using -dest:package=*.zip *or* to a remote folder using -dest:computername=%WMSVC%:8172/msdeploy.axd,package=*.zip.

    Also your :”Server Level Backup” command example is missing a few “:”, for whatever that’s worth.

    1. Eric Parvin says:

      Thanks Cori. I will take a look the command I have posted. I has been awhile since that post and I have probably have adjusted a few scripts 🙂

Comments are closed.

Skip to main content