title: Microsoft Web Deploy backup fails and doesn't recover
body: <p>I've recently started working with Microsoft Web Deploy.</p>
  <p>I got backups working in a basic configuration and now I'd like to experiment with adding some folder exclusions to the <code>.pubxml</code> file in my projects based on <a href="https://stackoverflow.com/a/32720312/3059082">the comments to this answer</a>.</p>
  <p>Here are my deploy settings:</p>
  <pre><code>    cd &quot;\Program Files\IIS\Microsoft Web Deploy V3\scripts\&quot;
      . .\BackupScripts.ps1
      Reset-BackupSettings
      TurnOn-Backups -On $true
      Configure-Backups -Enabled $true
      Configure-Backups -ContinueSyncOnBackupFailure $false
      Configure-Backups -NumberOfBackups 5
      Configure-Backups -BackupPath &quot;D:\UAT\AppBackups\{siteName}_snapshots&quot;
      Configure-BackupSettingsProvider -CanAddExcludedProviders $true
      Get-BackupSettings
  </code></pre>
  <p>This works until I paste this snippet into my publish profile:</p>
  <pre><code>    &lt;Target Name=&quot;AddCustomSkipRules&quot;&gt; 
        &lt;ItemGroup&gt;
          &lt;MsDeploySkipRules Include=&quot;SkipAppDataFolder&quot;&gt;
            &lt;SkipAction&gt;&lt;/SkipAction&gt;
            &lt;ObjectName&gt;dirPath&lt;/ObjectName&gt;
            &lt;AbsolutePath&gt;$(_DestinationContentPath)\\App_Data$&lt;/AbsolutePath&gt;
            &lt;Apply&gt;Destination&lt;/Apply&gt;
            &lt;XPath&gt;&lt;/XPath&gt;
          &lt;/MsDeploySkipRules&gt;
        &lt;/ItemGroup&gt;
      &lt;/Target&gt;
  </code></pre>
  <p>A publish attempt with that code fails, and then seems to get stuck.  Removing the snippet and republishing still fails.</p>
  <p>Here's the error I get from the trace:</p>
  <pre><code>&gt;trace eventLevel=&quot;Error&quot; message=&quot;BACKUP_FAILED - Skipping backup because it failed due to an unknown reason.%C2%A0For more information, contact your server administrator.&quot;
  </code></pre>
  <pre><code>AspNetModuleDiagErrorEvent  
  Uri /msdeploy.axd  
    
  User: username  
  Client IP: 10.148.69.225  
  Content-Type: application/msdeploy  
  Version: 9.0.0.0  
  MSDeploy.VersionMin: 7.1.600.0  
  MSDeploy.VersionMax: 9.0.3802.0  
  MSDeploy.Method: Sync  
  MSDeploy.RequestId: fa27c81c-12aa-47f3-ac37-7ea94caa14a4  
  MSDeploy.RequestCulture: en-US  
  MSDeploy.RequestUICulture: en-US  
  ServerVersion: 9.0.1973.0  
  Skip: objectName=&quot;^configProtectedData$&quot;  
  Provider: auto, Path: A tracing deployment agent exception occurred that was propagated to the client.  
  Request ID   'fa27c81c-12aa-47f3-ac37-7ea94caa14a4'.  
  Request Timestamp: '11/10/2021 5:08:45 PM'.  
  Error Details:  
      System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.  
      at Microsoft.Web.Deployment.BackupManager.HandleExceptionForBackupFailure(DeploymentBaseContext baseContext, BackupSettings settings, Exception ex, Boolean suppressLogging)  
      at Microsoft.Web.Deployment.BackupRuleHandler.PreSync(DeploymentSyncContext syncContext)  
      at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)  
      at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable``1 syncPassId, String syncSessionId)  
      at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId, String user, String siteName)  
      at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)  
      at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)
  </code></pre>
  <p>Restarting IIS or the Web Deploy service doesn't help and I'd rather not restart the entire server if I can help it.</p>
  <p>How can I get the backup service unstuck?</p>