dsccommunity / dsccommunity/SqlServerDsc
SqlAGDatabase: Add parameter to retain backup files
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 385
- Forks
- 224
- PR merge metrics
- No merged PRs in 30d
Description
Details of the scenario you tried and the problem that is occurring
I am using SqlAGDatabase with the win_dsc module in Ansible in order to add the databases to the AG and its getting added as well but no .bak and .trn file is created at the mention backup path
The DSC configuration that is used to reproduce the issue (as detailed as possible)
SqlAGDatabase 'TestAGDatabaseMemberships'
{
AvailabilityGroupName = $Node.AvailabilityGroupName
BackupPath = '\\SQL1\AgInitialize'
DatabaseName = 'DB*', 'AdventureWorks'
InstanceName = $Node.InstanceName
ServerName = $Node.NodeName
Ensure = 'Present'
ProcessOnlyOnActiveNode = $true
PsDscRunAsCredential = $SqlAdministratorCredential
}
But the above i am passing as below via Ansible
- name: Add Database to Always On Availability Group in "{{ groups['windows'][0] }}"
when: inventory_hostname in groups['windows'][0]
win_dsc:
resource_name: SqlAGDatabase
DatabaseName: D*, Test*
ServerName: WINSER1
InstanceName: MSSQLSERVER
AvailabilityGroupName: TEST_AG
BackupPath: \\WINSER1\backup_demo (shared network folder created in the winser1 server)
Ensure: Present
SQL Server edition and version the target node is running
Microsoft SQL Server 2016 (SP2) (KB4052908) - 13.0.5026.0 (X64)
SQL Server PowerShell modules present on the target node
Name Version Path
---- ------- ----
SqlServer 21.1.18147 C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.1.18121\SqlServer.psd1
SQLPS 14.0 C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules\SQLPS\SQLPS.psd1
The operating system the target node is running
OsName : Microsoft Windows Server 2012 R2 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsBuildLabEx : 9600.17415.amd64fre.winblue_r4.141028-1500
OsLanguage : en-US
OsMuiLanguages : {en-US}
Version and build of PowerShell the target node is running
Name Value
---- -----
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version of the DSC module that was used ('dev' if using current dev branch)
Name Version Path
---- ------- ----
SqlServerDsc 12.4.0.0 C:\Program Files\WindowsPowerShell\Modules\SqlServerDsc\12.4.0.0\SqlServerDsc.psd1
Refer the screenshot below which shows that the Ansible run successful and it added the DB to the AG but no .bak and .trn file is create in \WINSER1\backup_demo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the SqlAGDatabase resource and its BackupPath handling, then review how Always On database initialization creates or removes .bak and .trn files. Confirm the intended retention behavior for the new parameter against the reported Ansible scenario and SQL Server 2016 environment. Done means the parameter controls whether those backup files are retained as requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100