Checking last backup date
In this recipe, we will check when databases have been last backed up.
Getting ready
One way to check when a database was last backed up is through SQL Server Management Studio. Open SSMS and connect to your instance. For example, if you want to see when AdventureWorks2014
was last backed up, you can right-click on this database and select Properties. In the General page, you should see a section for Backup, which should show you when a database and log were last backed up.
How to do it...
The steps to check the last backup dates are as follows:
Open PowerShell ISE as administrator.
Import the
SQLPS
module as follows:#import SQL Server module Import-Module SQLPS -DisableNameChecking
Add the following script and run:
$instanceName = "localhost" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName $server.Databases | Select-Object Name, RecoveryModel, LastBackupDate, LastDifferentialBackupDate, LastLogBackupDate | Format-Table...