< Back

Get-DbaLastBackup

Mon Jan 13, 2020 11:12 am

NAME Get-DbaLastBackup



SYNOPSIS

Get date/time for last known backups of databases.





SYNTAX

Get-DbaLastBackup [-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]> [[-SqlCredential]

<Pscredential>] [[-Database] <System.Object[]>] [[-ExcludeDatabase] <System.Object[]>] [-EnableException <Switch>]

[<CommonParameters>]





DESCRIPTION

Retrieves and compares the date/time for the last known backups, as well as the creation date/time for the

database.



Default output includes columns Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup,

SinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated.





PARAMETERS

-Database [<System.Object[]>]

Specifies one or more database(s) to process. If unspecified, all databases will be processed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

If this switch is enabled exceptions will be thrown to the caller, which will need to perform its own

exception processing. Otherwise, the function will try to catch the exception, interpret it and provide a

friendly error message.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ExcludeDatabase [<System.Object[]>]

Specifies one or more database(s) to exclude from processing.



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 [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances.



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: DisasterRecovery, Backup

Author: Klaas Vandenberghe (@PowerDBAKlaas)



Website: https://dbatools.io

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

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



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-DbaLastBackup -SqlInstance ServerA\\sql987



Returns a custom object displaying Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup,

SinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-DbaLastBackup -SqlInstance ServerA\\sql987



Returns a custom object with Server name, Database name, and the date the last time backups were performed.

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-DbaLastBackup -SqlInstance ServerA\\sql987 | Select-Object *



Returns a custom object with Server name, Database name, and the date the last time backups were performed, and

also recoverymodel and calculations on how long ago backups were taken and what the status is.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Get-DbaLastBackup -SqlInstance ServerA\\sql987 | Select-Object * | Out-Gridview



Returns a gridview displaying Server, Database, RecoveryModel, LastFullBackup, LastDiffBackup, LastLogBackup,

SinceFull, SinceDiff, SinceLog, Status, DatabaseCreated, DaysSinceDbCreated.



RELATED LINKS

https://dbatools.io/Get-DbaLastBackup