Get Last Database Restore Date and Time in SQL Server

This guide provides a script to retrieve the last restore date and time for each database in SQL Server. It’s particularly helpful for tracking restore operations or verifying backups during disaster recovery scenarios.

The script below queries the sys.databases and dbo.restorehistory system tables to get the most recent restore details for each database.

If a database wasn’t created via a restore (e.g., created manually or during SQL Server installation), the restore_date column will return NULL. In such cases, this script may not provide meaningful results.

Here’s the SQL script:

database last restore time sql

Restore Types: The restore_type column indicates the restore operation type:
> D: Full backup restore
> L: Transaction log restore
> I: Differential restore
Refer to MS Docs for detailed column descriptions.

For more tips on SQL Server backups from an experienced SQL DBA, checkout my database backup & recovery tag!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Error Messages (5) Failover Cluster Instances (FCI) (1) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Administration (2) Logging & Monitoring (1) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (2) SQL Certificates & Encryption (3) SQL Server Agent (5) SQL Server CDC (2) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (16) SQL Server Networking (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance Tuning (6) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) SQL Server Security (4) SQL Server Storage (10) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)