dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Select-DbaBackupInformation

Select a subset of backups from a dbatools backup history object.

Screenshots

dbatools-Select-DbaBackupInformation

Examples

Returns all backups needed to restore all the backups in \server1\backups$ to 1 hour ago.

$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \server1\backups$
$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1)

Returns all the backups needed to restore Database ProdFinance to an hour ago.

$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \server1\backups$
$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -DatabaseName ProdFinance

Returns all the backups in \server1\backups$ to restore to as close prior to 1 hour ago as can be managed with only full and differential backups.

$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \server1\backups$
$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreLogs

Returns all the backups in \server1\backups$ to restore to 1 hour ago using only Full and Log backups.

$Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \server1\backups$
$FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreDiffs

Author

This command was created by Stuart Moore. You can find Stuart on Twitter and his blog.

Get-Help

From PowerShell, execute Get-Help Select-DbaBackupInformation -Detailed for more information on this function.

Source Code

Want to see the source code? View Select-DbaBackupInformation.ps1 on GitHub
 

Related commands