< Back

Test-DbaBackupInformation

Mon Jan 13, 2020 6:00 pm

NAME Test-DbaBackupInformation



SYNOPSIS

Tests a dbatools backup history object is correct for restoring





SYNTAX

Test-DbaBackupInformation [-BackupHistory] <System.Object[]> [[-SqlInstance] <DbaInstanceParameter>]

[[-SqlCredential] <Pscredential>] [-WithReplace <Switch>] [-Continue <Switch>] [-VerifyOnly <Switch>]

[-OutputScriptOnly <Switch>] [-EnableException <Switch>] [<CommonParameters>]





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





PARAMETERS

-BackupHistory [<System.Object[]>]

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

`Format-DbaBackupInformation`



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Continue [<Switch>]

Switch to indicate a continuing restore



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-OutputScriptOnly [<Switch>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<DbaInstanceParameter>]

The Sql Server instance that wil be performing the restore



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-VerifyOnly [<Switch>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-WithReplace [<Switch>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Backup, Restore, DisasterRecovery

Author: Stuart Moore (@napalmgram), stuart-moore.com



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



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



RELATED LINKS

https://dbatools.io/Test-DbaBackupInformation