Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner

internet.commerce
Be a Commerce Partner


















Security Software Primed for Strong Growth

SAP Touts 'Unwired' Strategy With Sybase

Salesforce Q2 Sees SaaS Paying Off

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2









SAP Administrator Sr
Next Step Systems
US-PA-Philadelphia

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

August 18, 2004

Restoring a SQL Database

By Muthusamy Anantha Kumar aka The MAK

When we create a backup maintenance plan with one Full backup and transaction log backups for every 15 minutes, it is sometimes necessary to restore the FULL backup and all the corresponding transactional backups sequentially. This may happen if the production box goes down or if you want to have the same database restored to another Server, etc. It is tiresome to locate all the transaction log backups and restore them one by one.

In this article, I would like to guide SQL Server DBAs to use a procedure, which can:

1.  Generate the script for restoring a full backup and all corresponding transaction log backups.

2.  Restore a full backup and all corresponding transaction log backups along with generated scripts.

3.  Restore the latest full backup and all corresponding transaction log backups as a different database.

This procedure uses xp_cmdshell and the MS-DOS 'DIR' command to find the backup and transactions log sequence based on the file date.

Let us simulate the whole backup and restore process.

Step 1

Create a database, "Inventory," in FULL recovery mode. (You can use the below script):

Use master
Go
CREATE DATABASE [inventory]  
  ON (NAME = N'inventory', 
  FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL\data\inventory.mdf' , 
  SIZE = 1, FILEGROWTH = 10%) 
LOG ON (NAME = N'inventory_log', 
  FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL\data\Inventory_log.LDF' , 
  FILEGROWTH = 10%)
Go
Alter DATABASE [inventory]  set recovery FULL
GO

Step 2

Create a maintenance plan with one full backup, (as shown in figure Fig 1.0), and transaction log backup for every 5 minutes, (as shown in figure Fig 2.0).


Fig 1.0


Fig 2.0

When this maintenance plan runs, it creates .BAK and .TRN files as shown in the figure Fig 3.0.


Fig 3.0



Go to page: 1  2  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives








Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SSRS, Sharepoint or ASP.NET kappa02 1 August 31st, 08:59 AM
Ad/ldap & sql 2005 (7321) kappa02 4 August 30th, 03:58 PM
Sql SerVer Restore SaranSaki 3 August 27th, 02:15 PM
DTS Excel data exceeds 65536 rows ssingh 1 August 13th, 09:55 AM