Skip to content

Commit

Permalink
Merge branch 'development' into datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed May 16, 2024
2 parents 7f98035 + d485883 commit b17583d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
10 changes: 9 additions & 1 deletion public/Backup-DbaDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ function Backup-DbaDatabase {
timestamp - will be replaced with the timestamp (either the default, or the format provided)
backuptype - will be replaced with Full, Log or Differential as appropriate
.PARAMETER NoAppendDbNameInPath
A switch that will prevent to systematically appended dbname to the path when creating the backup file path
.PARAMETER CopyOnly
If this switch is enabled, CopyOnly backups will be taken. By default function performs a normal backup, these backups interfere with the restore chain of the database. CopyOnly backups will not interfere with the restore chain of the database.
Expand Down Expand Up @@ -217,6 +220,7 @@ function Backup-DbaDatabase {
[string]$FilePath,
[switch]$IncrementPrefix,
[switch]$ReplaceInName,
[switch]$NoAppendDbNameInPath,
[switch]$CopyOnly,
[ValidateSet('Full', 'Log', 'Differential', 'Diff', 'Database')]
[string]$Type = 'Database',
Expand Down Expand Up @@ -661,7 +665,11 @@ function Backup-DbaDatabase {
for ($i = 0; $i -lt $FinalBackupPath.Count; $i++) {
$parent = [IO.Path]::GetDirectoryName($FinalBackupPath[$i])
$leaf = [IO.Path]::GetFileName($FinalBackupPath[$i])
$FinalBackupPath[$i] = [IO.Path]::Combine($parent, $dbName, $leaf)
if ($NoAppendDbNameInPath) {
$FinalBackupPath[$i] = [IO.Path]::Combine($parent, $leaf)
} else {
$FinalBackupPath[$i] = [IO.Path]::Combine($parent, $dbName, $leaf)
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions public/New-DbaAvailabilityGroup.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function New-DbaAvailabilityGroup {
function New-DbaAvailabilityGroup {
<#
.SYNOPSIS
Automates the creation of availability groups.
Expand Down Expand Up @@ -382,13 +382,13 @@
}

if ($IsContained -and $server.VersionMajor -lt 16) {
Stop-Function -Level Warning -Message "Contained availability groups are only supported in SQL Server 2022 and above"
return
Stop-Function -Message "Contained availability groups are only supported in SQL Server 2022 and above" -Target $Primary
return
}

if ($ReuseSystemDatabases -and $IsContained -eq $false) {
Stop-Function -Level Warning -Message "Reuse system databases is only applicable in contained availability groups"
return
Stop-Function -Message "Reuse system databases is only applicable in contained availability groups" -Target $Primary
return
}

Write-ProgressHelper -StepNumber ($stepCounter++) -Message "Checking requirements"
Expand Down Expand Up @@ -698,4 +698,4 @@
# Get results
Get-DbaAvailabilityGroup -SqlInstance $Primary -SqlCredential $PrimarySqlCredential -AvailabilityGroup $Name
}
}
}
2 changes: 1 addition & 1 deletion tests/Backup-DbaDatabase.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan
Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
[object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object { $_ -notin ('whatif', 'confirm') }
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Path', 'FilePath', 'ReplaceInName', 'CopyOnly', 'Type', 'InputObject', 'CreateFolder', 'FileCount', 'CompressBackup', 'Checksum', 'Verify', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'AzureBaseUrl', 'AzureCredential', 'NoRecovery', 'BuildPath', 'WithFormat', 'Initialize', 'SkipTapeHeader', 'TimeStampFormat', 'IgnoreFileChecks', 'OutputScriptOnly', 'EnableException', 'EncryptionAlgorithm', 'EncryptionCertificate', 'IncrementPrefix', 'Description'
[object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Path', 'FilePath', 'ReplaceInName', 'NoAppendDbNameInPath', 'CopyOnly', 'Type', 'InputObject', 'CreateFolder', 'FileCount', 'CompressBackup', 'Checksum', 'Verify', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'AzureBaseUrl', 'AzureCredential', 'NoRecovery', 'BuildPath', 'WithFormat', 'Initialize', 'SkipTapeHeader', 'TimeStampFormat', 'IgnoreFileChecks', 'OutputScriptOnly', 'EnableException', 'EncryptionAlgorithm', 'EncryptionCertificate', 'IncrementPrefix', 'Description'
$knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters
It "Should only contain our specific parameters" {
(@(Compare-Object -ReferenceObject ($knownParameters | Where-Object { $_ }) -DifferenceObject $params).Count ) | Should Be 0
Expand Down
2 changes: 1 addition & 1 deletion tests/New-DbaAvailabilityGroup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Describe "$commandname Integration Tests" -Tag "IntegrationTests" {
$results.AvailabilityDatabases.Count | Should -Be 0 -Because "No database was named"
}
}
} #$script:instance2 for appveyor
} #$script:instance2 for appveyor

0 comments on commit b17583d

Please sign in to comment.