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


Get-DbaBackupHistory

This command returns backup history details for some or all databases on a SQL Server. You can even get detailed information (including file path) for latest full, differential and log files.

Screenshots

Examples

To return server name, database, username, backup type, date for all backups databases on sqlserver2014a. This may return a ton of rows; consider using filters that are included in other examples.

Get-DbaBackupHistory -SqlServer sqlserver2014a

To return backup information only for databases db1 and db2 on sqlserve2014a since July 1, 2016 at 10:47 AM.

Get-DbaBackupHistory -SqlServer sqlserver2014a -Databases db1, db2 -Since ‘7/1/2016 10:47:00’

To return information only for AdventureWorks2014 and pubs, and makes the output pretty

Get-DbaBackupHistory -SqlServer sql2014 -Databases AdventureWorks2014, pubs -Force | Format-Table

To return information about the most recent full, differential and log backups for AdventureWorks2014 on sql2014

Get-DbaBackupHistory -SqlServer sql2014 -Databases AdventureWorks2014 -Last

To return information about the most recent full backup for AdventureWorks2014 on sql2014

Get-DbaBackupHistory -SqlServer sql2014 -Databases AdventureWorks2014 -LastFull

To return database backup information for every database on every server listed in the Central Management Server on sql2016

Get-SqlRegisteredServerName -SqlServer sql2016 | Get-DbaBackupHistory

References

Find Your Backup History at sqlhub.com

Get-Help

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

Source Code

Want to see the source code? View Get-DbaBackupHistory.ps1 on GitHub
 

Related commands