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

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

Restore last backup to a different server/database

By Cyanide,

Finds the last available backup for a specified database (local or remote server), then restores the backup onto an existing database on the local server.
The script will kill all non-system processes in the destination database to allow the script to be scheduled at night regardless is anyone is still connected.
The logical and physical names are preserved incase of non-standard data and log file suffixes.

I wrote this script as the developers I work with are constantly asking for copies of live databases onto testing servers.

It has been tested on multiple servers in my environment.
The source server must be a linked server to the current server to allow the script to find the last backup details.
The script also relies on the standard administrative shares to access the backupfile, so the login context must have administrative access to the source server.

Total article views: 734 | Views in the last 30 days: 2
 
Related Articles
ARTICLE

Powershell Database Backup Script

Learn how to write a script for regular database backups using Powershell and SMO.

SCRIPT

Script to Get the Backup History

Script to get the database backup history on SQL Server 2000/2005/2008

BLOG

Script: Backup All your Databases

We all know the importance of taking regular backups of our SQL Server databases. This is a useful l...

FORUM

Server Database Backup

Server Database Backup

SCRIPT

Backup & Restoration Script

This script provides very useful information about database backup and restoration.

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