SQL Clone
SQLServerCentral is supported by Redgate
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: 744 | Views in the last 30 days: 1
Related Articles

Powershell Database Backup Script

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


Script to Get the Backup History

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


Script: Backup All your Databases

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


Server Database Backup

Server Database Backup


Backup & Restoration Script

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