commands

^

Test-DbaBackupInformation

Author Stuart Moore (@napalmgram), stuart-moore.com
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Test-DbaBackupInformation on GitHub.
Want to see the Bill Of Health for this command? Check out Test-DbaBackupInformation.

Synopsis

Tests a dbatools backup history object is correct for restoring

Description

Input is normally from a backup history object generated from Format-DbaBackupInformation. This is then parse to check that it's valid for restore. Tests performed include:

  • Checking unbroken LSN chain
  • If the target database exists and WithReplace has been provided
  • If any files already exist, but owned by other databases
  • Creates any new folders required
  • That the backup files exists at the location specified, and can be seen by the Sql Instance
  • If no errors are found then the objects for that database will me marked as Verified

Syntax

Test-DbaBackupInformation
    [-BackupHistory] <Object[]>
    [[-SqlInstance] <DbaInstanceParameter>]
    [[-SqlCredential] <PSCredential>]
    [-WithReplace]
    [-Continue]
    [-VerifyOnly]
    [-OutputScriptOnly]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> $BackupHistory | Test-DbaBackupInformation -SqlInstance MyInstance
PS C:\> $PassedDbs = $BackupHistory | Where-Object {$_.IsVerified -eq $True}
PS C:\> $FailedDbs = $BackupHistory | Where-Object {$_.IsVerified -ne $True}

Pass in a BackupHistory object to be tested against MyInstance.
Those records that pass are marked as verified. We can then use the IsVerified property to divide the failures and successes

Required Parameters

-BackupHistory

dbatools BackupHistory object. Normally this will have been process with Select- and then Format-DbaBackupInformation

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlInstance

The Sql Server instance that wil be performing the restore

Alias
Required False
Pipeline false
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-WithReplace

By default we won't overwrite an existing database, this switch tells us you want to

Alias
Required False
Pipeline false
Default Value False
-Continue

Switch to indicate a continuing restore

Alias
Required False
Pipeline false
Default Value False
-VerifyOnly

This switch indicates that you only wish to verify a restore, so runs a smaller number of tests as you won't be writing anything to the restore server

Alias
Required False
Pipeline false
Default Value False
-OutputScriptOnly

Switch to disable path creation. Will write a warning that a path does not exist

Alias
Required False
Pipeline false
Default Value False
-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.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before running the cmdlet.

Alias cf
Required False
Pipeline false
Default Value