Author | Stuart Moore (@napalmgram), stuart-moore.com |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Select-DbaBackupInformation on GitHub.
Want to see the Bill Of Health for this command? Check out Select-DbaBackupInformation.
Filters backup history to identify the minimum backup chain needed for point-in-time database recovery
Analyzes backup history objects and determines the exact sequence of backups required to restore a database to a specific point in time. This function handles the complex LSN logic to identify which full, differential, and log backups are needed, eliminating the guesswork of manual restore planning. It supports continuing interrupted restores, filtering by database or server names, and accommodating different restore strategies by optionally ignoring differential or log backups. Perfect for automating disaster recovery procedures or when you need to restore to a precise moment without restoring unnecessary backup files.
Select-DbaBackupInformation
[-BackupHistory] <Object>
[[-RestoreTime] <DateTime>]
[-IgnoreLogs]
[-IgnoreDiffs]
[[-DatabaseName] <String[]>]
[[-ServerName] <String[]>]
[[-ContinuePoints] <Object>]
[[-LastRestoreType] <Object>]
[-EnableException]
[<CommonParameters>]
PS C:\> $Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\server1\backups$
PS C:\> $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1)
Returns all backups needed to restore all the backups in \server1\backups$ to 1 hour ago
PS C:\> $Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\server1\backups$
PS C:\> $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -DatabaseName ProdFinance
Returns all the backups needed to restore Database ProdFinance to an hour ago
PS C:\> $Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\server1\backups$
PS C:\> $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreLogs
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
PS C:\> $Backups = Get-DbaBackupInformation -SqlInstance Server1 -Path \\server1\backups$
PS C:\> $FilteredBackups = $Backups | Select-DbaBackupInformation -RestoreTime (Get-Date).AddHours(-1) -IgnoreDiffs
Returns all the backups in \server1\backups$ to restore to 1 hour ago using only Full and Log backups.
Backup history records from Get-DbaBackupInformation containing backup metadata and file paths.
This function analyzes these records to determine the minimum backup chain needed for point-in-time recovery.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
The specific point in time to restore the database to. Defaults to one month in the future if not specified.
Use this when you need to recover to a specific moment, such as just before a data corruption incident occurred.
Alias | |
Required | False |
Pipeline | false |
Default Value | (Get-Date).addmonths(1) |
Excludes transaction log backups from the restore chain, limiting recovery to the most recent full or differential backup.
Use this when you don't need point-in-time recovery or when log backups are unavailable or corrupted.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Excludes differential backups from the restore chain, using only full backups and transaction logs.
Use this when differential backups are corrupted or when you want to test a restore strategy using only full and log backups.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Filters results to only include backup chains for the specified database names. Accepts wildcards.
Use this when you only need to restore specific databases from a backup set containing multiple databases.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Filters results to only include backups from the specified server or availability group names.
For Availability Groups, this filters by the AG name rather than individual replica server names.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Output from Get-RestoreContinuableDatabase containing LSN and fork information for resuming interrupted restores.
Use this when continuing a partial restore operation on a database that's already in a restoring state.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Output from Get-DbaDbRestoreHistory -Last showing the most recent restore operation performed on the target database.
This determines whether differential backups can be applied based on the last restore type performed.
Alias | |
Required | False |
Pipeline | false |
Default Value |
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 |