Browse files


  • Loading branch information...
potatoqualitee committed Feb 9, 2019
1 parent 1d9f8f9 commit b68144090ef32d2a895cf2f84bb3b18e657cbc96
} elseif (-not $WithReplace -and (-not $VerifyOnly)) {
Stop-Function -Message "$Database exists and WithReplace not specified, stopping" -EnableException $EnableException
Write-Message -Level verbose -Message "$Database exists and WithReplace not specified, stopping"
Write-Message -Message "WithReplace = $WithReplace" -Level Debug
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

.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.

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

PS C:\> $BackupHistory = Get-DbaBackupInformation -SqlInstance sql2005 -Path \\backups\sql2000\ProdDb
[parameter(ParameterSetName = "Restore")][string]$DestinationFileSuffix,
[parameter(ParameterSetName = "Recovery")][switch]$Recover,
[parameter(ParameterSetName = "Restore")][switch]$KeepCDC,
[parameter(Mandatory, ParameterSetName = "RestorePage")][object]$PageRestore,
[parameter(Mandatory, ParameterSetName = "RestorePage")][string]$PageRestoreTailFolder,
[int]$StatementTimeout = 0
[int]$StatementTimeout = 0,
begin {
Write-Message -Level InternalComment -Message "Starting"
$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
$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"
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) {
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

Oops, something went wrong.

0 comments on commit b681440

Please sign in to comment.