-
-
Notifications
You must be signed in to change notification settings - Fork 829
New-DbaDbSnapshot: Add Basic Availability Group Support #9632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
public/New-DbaDbSnapshot.ps1
Outdated
@@ -188,6 +188,9 @@ function New-DbaDbSnapshot { | |||
Write-Message -Level Warning -Message "$($db.name) is a snapshot, skipping" | |||
} elseif ($db.name -in $NoSupportForSnap) { | |||
Write-Message -Level Warning -Message "$($db.name) snapshots are prohibited" | |||
} elseif ($db.IsAccessible -ne $true -and EngineEdition -eq "Standard" -and -not [string]::IsNullOrEmpty($db.AvailabilityGroupName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmmh, this "EngineEdition" doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, why checking for the edition if the point is that if it's part of a group is allowed ?
also, the fact that it's part of an availability group suffices or MUST be a secondary, too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmmh, this "EngineEdition" doesn't exist
Oh. That was careless. Thanks @niphlod
also, why checking for the edition if the point is that if it's part of a group is allowed ?
also, the fact that it's part of an availability group suffices or MUST be a secondary, too ?
I'm only trying to address the part that I know is broken. I haven't thought to check if this is also broken on normal AGs. If it is, then I'm stunned that I was the first to find it.
I'm worried that, if I'm not too lenient, I'll be making databases that ought to have been treated as truly unaccessible instead fall on to my new branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be fair, the whole "ordeal" is just a "correct-er" filtering of databases, so you can test it just with (pseudo-code)
$server = Connect-DbaInstance -SqlInstance <yourinstance> -MinimumVersion 9
$dbs = $server.Databases
....
$theListOfMyDbs = @()
foreach ($db in $dbs) {
if ($db.IsMirroringEnabled) {
$theListOfMyDbs += $db
} elseif ($db.IsDatabaseSnapshot) {
Write-Message -Level Warning -Message "$($db.name) is a snapshot, skipping"
} elseif ($db.name -in $NoSupportForSnap) {
Write-Message -Level Warning -Message "$($db.name) snapshots are prohibited"
... add your own filters
} elseif ($db.IsAccessible -ne $true) {
Write-Message -Level Verbose -Message "$($db.name) is not accessible, skipping"
} else {
$theListOfMyDbs += $db
}
}
$theListOfMyDbs
so you don't even need to be able to get the source code and run your own version of new-dbadbsnapshot.
I'm worried that, if I'm not too lenient, I'll be making databases that ought to have been treated as truly unaccessible instead fall on to my new branch.
Given the issue is that "I want to run on SECONDARIES" I'd expect the filter to account for that, too.
@ReeceGoding , nothing to build. Just clone the repo or download the zip and import-module dbatools.psd1 from there . |
Oh. It's that easy? I'll have to try it, but not tonight. I've been looking for an excuse to get PowerShell working on my Linux machine. |
5f75481
to
1c924ee
Compare
…bility Group is a valid target).
@niphlod Thanks for the massive tips. I think this finally works. As you suspected, there's nothing special about BAGs. Any AG database that isn't considered readable was impacted by this. |
Should close #9631... In theory. This is just my quick best guess made in the GitHub GUI. I don't have PowerShell installed on this machine and, to be embarrassingly honest, I don't think that I ever learned how to build dbatools correctly even on my proper machine.
Type of Change
Invoke-ManualPester
)Purpose
Test for BAGs, then snapshot if so.
Approach
As above.
Commands to test
Just
New-DbaDbSnapshot
. However, once this is working, I should see if the other snapshot commands support BAGs.Screenshots
N/A
Learning
N/A