2

I am using web deploy to publish my .net core 3.1 web app to my server, which is working fine so far. Now I want to setup automatic backup before any new deployments. I followed this manual.

I've also added <EnableMSDeployBackup>True</EnableMSDeployBackup> to my .pubxml file. When I initiate a deployment with dotnet publish ... The console output tells that a backup will be created. No errors are reported. And actually there is a package zip-file at the defined backup location, but the content folder does not contain anything, there is only an archive.xml and systemInfo.xml file in the root of the zip.

When I perform the backup using msdeploy.exe -verb:sync -source:backupManager -dest:backupManager=siteName directly on the server, the backup is created properly. For testing I'm using the same user for remote-publish who is administrator on the server and has full rights in the source as well as in the destination folder.

The behaviour is the same when publishing from within Visual Studio 2019.

I've already found some similar questions here and here but none of the recommended solutions work.

My .pubxml looks like this (mostly created from VS):

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <EnvironmentName>Production</EnvironmentName>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>https://my-server/myapp</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <TargetFramework>net461</TargetFramework>
    <RuntimeIdentifier>win7-x86</RuntimeIdentifier>
    <ProjectGuid>3ae552b0-7f3a-42b9-b224-d5c734004215</ProjectGuid>
    <MSDeployServiceURL>https://my-server/</MSDeployServiceURL>
    <DeployIisAppPath>MyApp</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>ourDomain\myUser</UserName>
    <_SavePWD>True</_SavePWD>
    <PublishDatabaseSettings>
      <Objects xmlns="" />
    </PublishDatabaseSettings>
    <ExcludeFilesFromDeployment>appsettings.Development.json</ExcludeFilesFromDeployment>
  </PropertyGroup>
</Project>

Any ideas will be appreciated!

Lightbringer
  • 765
  • 1
  • 4
  • 16
  • Ever find the solution? I'm also having this problem – mejobloggs Aug 03 '22 at 04:22
  • Yes, I got it working, but I'm not completely sure anymore what was the exact reason of the issue. If I rember correctly, I tried to put the path of a nested application into the backup configuration, which does not work. Instead you have to provide only the parent site name. This results in creating a complete backup of the site even if you only publish one application, but at least it works. – Lightbringer Sep 06 '22 at 12:09

1 Answers1

0

The solution for me was to give read access to the account "LOCAL SERVICE" one folder above the website

Example matching my setup:

  • /IIS_Websites/ProjectName/WebRoot
  • Give "LOCAL SERVICE" read permission to ProjectName folder
  • Set WebRoot to inherit parent permission

There was a two-fold problem.

First, even though users such; as the deploy user, administrator group, IIS_IUSRS, App pool user; all had permission, it wasn't enough.

I found in Event Viewer - Security tab an Audit Success for the Publish User... but it said it was "Local Service" impersonating the Publish User. So I tried giving Local Service read access and it worked.

Second, I found every time I publish, it reset the permissions on the WebRoot folder, and reverted permissions just to inherited permissions. So setting Local Service access on WebRoot did not work since it got wiped every time.

mejobloggs
  • 7,937
  • 6
  • 32
  • 39