Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Script to find latest backups for all databases

By Roshan Joe Joseph,

Overview

There are at times when different teams have control over a particular server but you have the responsibility of restoring the database in case of disater. This is a tricky situation. If you dont have a policy regarding backups? You should have a record of recent backups in the server for each databases. If you have knowledge on say when was latest full/differential/log backup taken on a particualr database, you will not be totally lost in time of a catastrophe. If you are new to the environement, this script will give you an idea of what backup plan goes on each database. Especially if you administer multiple servers, it will help you document your backup locations.

How to use the script

The procedure uses msdb to get the relevent backups you need to look at.

The Procedure can be executed in 3 ways.

  1. EXEC USP_DBA_RECENTBACKUPS: This will detail all recent backups of all types (Full, differential and log ) for each database. Eg. If you take only full backups you will find only one record for each server.
  2. EXEC USP_DBA_RECENTBACKUPS '<DBNAME>': The same result as above. But here you are ineterested in a single database. It will list all recent backups of all types for the given databse.
  3. EXEC USP_DBA_RECENTBACKUPS '<DBNAME>','R': If you are having a simple backup plan of Full, differential and log backups, you can use this syntax to see what you need to restore the database. It will list latest full backup, latest differntial backup, and all the log backups therafter.

 

Hope this script will be useful for you.

Note:

  • There is no guarentee that the files listed in the backup history is available in the location. chances are someone might have moved/ deleted the records.
  • The data is retrived from msdb database. It is recomented that you save the results for whole server in an excel fie.

Total article views: 2242 | Views in the last 30 days: 11
 
Related Articles
FORUM

Differential Backup of Database

Differential Backup of Database failing due to ntbackup and SQL Server VSS Writer Service Running

FORUM

Differential backup in 2005

Differential backup in 2005

FORUM

Restore multiple Differential backups

Restore multiple Differential backups

SCRIPT

Restore database from a device containing multiple backups

Script to restore the LATEST full and differential backups from a SQL Server 2008 R2 backup device.

FORUM

Differential Backup Size

Differential Backup Size

Tags
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones