Skip to content

xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership fails to create backup #814

@4c74356b41

Description

@4c74356b41

Details of the scenario you tried and the problem that is occurring:
I'm trying to create a sql server alwaysOn group with a database. The database gets added to alwaysOn group and after that it fails when trying to do restore (i'm using a local path to be sure the backup gets created properly, but it doesn't). I can switch to network path as soon as backup starts working.
The DSC configuration that is using the resource (as detailed as possible):
full configuration here. I'm pasting a failing snippet. The path c:\setup exists.

        xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership DatabaseToAlwaysOn {
            AvailabilityGroupName = "${deploymentPrefix}-sql-ag"
            BackupPath            = "C:\setup"
            DatabaseName          = "ContosoClinic"
            SQLServer             = $env:COMPUTERNAME
            SQLInstanceName       = "MSSQLSERVER"
            
            DependsOn             = @("[xDatabase]DeployBacPac", "[xSQLServerAlwaysOnAvailabilityGroup]AvailabilityGroup" )
            Ensure                = "Present"
            PsDscRunAsCredential  = $DomainCreds
        }

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Microsoft Windows NT 6.3 (14393), SQL - 13.0.4435.0 (2016 SP1 latest on Azure)

Name                           Value
----                           -----
PSVersion                      5.1.14393.1532
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1532
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
SqlServer 21.0.17178
Version of the DSC module you're using, or 'dev' if you're using current dev branch:
ModuleVersion = '8.1.0.0'

Actual error:

VERBOSE: [2017-09-15 08:58:58Z] [ERROR] PowerShell DSC resource 
MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership  failed to execute 
Set-TargetResource functionality with error message: The operation on the 
database 'ContosoClinic' failed with the following errors: System.Exception: 
System.InvalidOperationException: Executing non-query failed on database 
'master'. ---> System.Management.Automation.MethodInvocationException: 
Exception calling "ExecuteNonQuery" with "1" argument(s): "ExecuteNonQuery 
failed for Database 'master'. " ---> 
Microsoft.SqlServer.Management.Smo.FailedOperationException: ExecuteNonQuery 
failed for Database 'master'.  ---> 
Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception 
occurred while executing a Transact-SQL statement or batch. ---> 
System.Data.SqlClient.SqlException: Cannot open backup device 
'C:\setup\ContosoClinic_Full_20170915085856.bak'. Operating system error 3(The 
system cannot find the path specified.).

RESTORE DATABASE is terminating abnormally.

   at 
Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSql
Action action, Object execObject, DataSet fillDataSet, Boolean catchException)

   at 
Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String 
sqlCommand, ExecutionTypes executionType, Boolean retry)

   --- End of inner exception stack trace ---

   at 
Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String 
sqlCommand, ExecutionTypes executionType, Boolean retry)

   at 
Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCo
llection sqlCommands, ExecutionTypes executionType, Boolean retry)

   at 
Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringColle
ction queries, ExecutionTypes executionType)

   at 
Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(StringCollection 
sqlCommands, ExecutionTypes executionType)

   --- End of inner exception stack trace ---

   at 
Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(StringCollection 
sqlCommands, ExecutionTypes executionType)

   at CallSite.Target(Closure , CallSite , Object , String )

   --- End of inner exception stack trace ---

   at 
System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(Functio
nContext funcContext, Exception exception)

   at 
System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(Interprete
dFrame frame)

   at 
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(In
terpretedFrame frame)

   at 
System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(In
terpretedFrame frame)

   --- End of inner exception stack trace ---. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions