diff --git a/functions/Invoke-DbaAdvancedRestore.ps1 b/functions/Invoke-DbaAdvancedRestore.ps1 index ef81d39066..01d96737a4 100644 --- a/functions/Invoke-DbaAdvancedRestore.ps1 +++ b/functions/Invoke-DbaAdvancedRestore.ps1 @@ -172,8 +172,8 @@ function Invoke-DbaAdvancedRestore { } } } elseif (-not $WithReplace -and (-not $VerifyOnly)) { - Stop-Function -Message "$Database exists and WithReplace not specified, stopping" -EnableException $EnableException - return + Write-Message -Level verbose -Message "$Database exists and WithReplace not specified, stopping" + continue } } Write-Message -Message "WithReplace = $WithReplace" -Level Debug diff --git a/functions/Restore-DbaDatabase.ps1 b/functions/Restore-DbaDatabase.ps1 index 1a6b7beff1..6dca60d50c 100644 --- a/functions/Restore-DbaDatabase.ps1 +++ b/functions/Restore-DbaDatabase.ps1 @@ -139,10 +139,6 @@ function Restore-DbaDatabase { .PARAMETER Recover If set will perform recovery on the indicated database - .PARAMETER AllowContinue - By default, Restore-DbaDatabase will stop restoring any databases if it comes across an error. - Use this switch to enable it to restore all databases without issues. - .PARAMETER GetBackupInformation Passing a string value into this parameter will cause a global variable to be created holding the output of Get-DbaBackupInformation @@ -181,6 +177,9 @@ function Restore-DbaDatabase { .PARAMETER PageRestoreTailFolder This parameter passes in a location for the tail log backup required for page level restore + .PARAMETER AllowContinue + This parameter has been deprecated and will be removed in v1.0 + .PARAMETER EnableException By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. @@ -295,11 +294,10 @@ function Restore-DbaDatabase { .EXAMPLE PS C:\> Get-DbaBackupHistory - SqlInstance server\instance1 -Database ProdFinance -Last | Restore-DbaDatabase -PageRestore - PS C:\> $SuspectPage -PageRestoreTailFolder c:\temp -TrustDbBackupHistory -AllowContinues + PS C:\> $SuspectPage -PageRestoreTailFolder c:\temp -TrustDbBackupHistory Gets a list of Suspect Pages using Get-DbaSuspectPage. The uses Get-DbaBackupHistory and Restore-DbaDatabase to perform a restore of the suspect pages and bring them up to date If server\instance1 is Enterprise edition this will be done online, if not it will be performed offline - AllowContinue is required to make sure we cope with existing files .EXAMPLE PS C:\> $BackupHistory = Get-DbaBackupInformation -SqlInstance sql2005 -Path \\backups\sql2000\ProdDb @@ -362,7 +360,6 @@ function Restore-DbaDatabase { [parameter(ParameterSetName = "Restore")][string]$DestinationFileSuffix, [parameter(ParameterSetName = "Recovery")][switch]$Recover, [parameter(ParameterSetName = "Restore")][switch]$KeepCDC, - [switch]$AllowContinue, [string]$GetBackupInformation, [switch]$StopAfterGetBackupInformation, [string]$SelectBackupInformation, @@ -373,7 +370,8 @@ function Restore-DbaDatabase { [switch]$StopAfterTestBackupInformation, [parameter(Mandatory, ParameterSetName = "RestorePage")][object]$PageRestore, [parameter(Mandatory, ParameterSetName = "RestorePage")][string]$PageRestoreTailFolder, - [int]$StatementTimeout = 0 + [int]$StatementTimeout = 0, + [switch]$AllowContinue ) begin { Write-Message -Level InternalComment -Message "Starting" @@ -390,8 +388,8 @@ function Restore-DbaDatabase { $UseDestinationDefaultDirectories = $true $paramCount = 0 - if (!(Test-Bound "AllowContinue") -and $true -ne $AllowContinue) { - $AllowContinue = $false + if (Test-Bound "AllowContinue") { + Write-Message -Level Warning -Message "AllowContinue is deprecated and will be removed in v1.0" } if (Test-Bound "FileMapping") { $paramCount += 1 @@ -683,12 +681,7 @@ function Restore-DbaDatabase { $DbUnVerified = ($FilteredBackupHistory | Where-Object { $_.IsVerified -eq $False } | Select-Object -Property Database -Unique).Database -join ',' - if ($AllowContinue) { - Write-Message -Message "$DbUnverified failed testing, AllowContinue set" -Level Verbose - } else { - Stop-Function -Message "Database $DbUnverified failed testing, AllowContinue not set, exiting" - return - } + Write-Message -Level Warning -Message "Database $DbUnverified failed testing, skipping" } If ($PSCmdlet.ParameterSetName -eq "RestorePage") { if (($FilteredBackupHistory.Database | select-Object -unique | Measure-Object).count -ne 1) { diff --git a/functions/Test-DbaBackupInformation.ps1 b/functions/Test-DbaBackupInformation.ps1 index 224f7a3be1..505b01362d 100644 --- a/functions/Test-DbaBackupInformation.ps1 +++ b/functions/Test-DbaBackupInformation.ps1 @@ -112,7 +112,7 @@ function Test-DbaBackupInformation { Write-Message -Level Verbose -Message "VerifyOnly = $VerifyOnly" If ($VerifyOnly -ne $true) { if ($null -ne $DbCheck -and ($WithReplace -ne $true -and $Continue -ne $true)) { - Stop-Function -Message "Database $Database exists, so WithReplace must be specified" -Target $database + Write-Message -Level Warning -Message "Database $Database exists, so WithReplace must be specified" -Target $database $VerificationErrors++ } diff --git a/tests/Restore-DbaDatabase.Tests.ps1 b/tests/Restore-DbaDatabase.Tests.ps1 index 96710f7687..ed96aedb56 100644 --- a/tests/Restore-DbaDatabase.Tests.ps1 +++ b/tests/Restore-DbaDatabase.Tests.ps1 @@ -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','Path','DatabaseName','DestinationDataDirectory','DestinationLogDirectory','DestinationFileStreamDirectory','RestoreTime','NoRecovery','WithReplace','XpDirTree','OutputScriptOnly','VerifyOnly','MaintenanceSolutionBackup','FileMapping','IgnoreLogBackup','UseDestinationDefaultDirectories','ReuseSourceFolderStructure','DestinationFilePrefix','RestoredDatabaseNamePrefix','TrustDbBackupHistory','MaxTransferSize','BlockSize','BufferCount','DirectoryRecurse','EnableException','StandbyDirectory','Continue','AzureCredential','ReplaceDbNameInFile','DestinationFileSuffix','Recover','KeepCDC','AllowContinue','GetBackupInformation','StopAfterGetBackupInformation','SelectBackupInformation','StopAfterSelectBackupInformation','FormatBackupInformation','StopAfterFormatBackupInformation','TestBackupInformation','StopAfterTestBackupInformation','PageRestore','PageRestoreTailFolder','StatementTimeout' + [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'DatabaseName', 'DestinationDataDirectory', 'DestinationLogDirectory', 'DestinationFileStreamDirectory', 'RestoreTime', 'NoRecovery', 'WithReplace', 'XpDirTree', 'OutputScriptOnly', 'VerifyOnly', 'MaintenanceSolutionBackup', 'FileMapping', 'IgnoreLogBackup', 'UseDestinationDefaultDirectories', 'ReuseSourceFolderStructure', 'DestinationFilePrefix', 'RestoredDatabaseNamePrefix', 'TrustDbBackupHistory', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'DirectoryRecurse', 'EnableException', 'StandbyDirectory', 'Continue', 'AzureCredential', 'ReplaceDbNameInFile', 'DestinationFileSuffix', 'Recover', 'KeepCDC', 'AllowContinue', 'GetBackupInformation', 'StopAfterGetBackupInformation', 'SelectBackupInformation', 'StopAfterSelectBackupInformation', 'FormatBackupInformation', 'StopAfterFormatBackupInformation', 'TestBackupInformation', 'StopAfterTestBackupInformation', 'PageRestore', 'PageRestoreTailFolder', 'StatementTimeout' $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 @@ -35,7 +35,7 @@ Describe "$CommandName Integration Tests" -Tag "IntegrationTests" { Context "Ensuring warning is thrown if database already exists" { $results = Restore-DbaDatabase -SqlInstance $script:instance2 -Path $script:appveyorlabrepo\singlerestore\singlerestore.bak -WarningVariable warning -WarningAction SilentlyContinue It "Should warn" { - $warning | Where-Object { $_ -like '*Test-DbaBackupInformation*Database*' } | Should Match "exists and WithReplace not specified, stopping" + $warning | Where-Object { $_ -like '*Test-DbaBackupInformation*Database*' } | Should Match "exists, so WithReplace must be specified" } It "Should not return object" { $results | Should Be $null