Restoring Data with Database Snapshots

Similar documents
Course 6419B: Configuring, Managing and Maintaining Windows Server 2008-based Servers

Course Outline. Course 6419 : Configuring, Managing and Maintaining Windows Server 2008-based Servers. Duration: 5 Days

SharePoint 2010 Document Sets: Better Ways To Manage Content

SPHOL207: Database Snapshots with SharePoint 2013

Configuring, Managing and Maintaining Windows Server 2008-based Servers

Trainer Preparation Guide for Course 10174A: Configuring and Administering Microsoft SharePoint 2010

ACTIVE MICROSOFT CERTIFICATIONS:

Microsoft SharePoint Server 2010: What s New and What s Changed?

HJ594S. Configuring, Managing and Mantaining Windows Server 2008 Servers (6419)


$99.95 per user. SQL Server 2005 Database Administration CourseId: 152 Skill level: Run Time: 30+ hours (158 videos)

ACTIVE MICROSOFT CERTIFICATIONS:

Course 20411D: Administering Windows Server 2012

EMC Replication Manager and Kroll Ontrack PowerControls for Granular Recovery of SharePoint Items

Exam : Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 2. Title : The safer, easier way to help you pass any IT exams.

DB2 9 for LUW Advanced Database Recovery CL492; 4 days, Instructor-led

Library Recovery Center

Implementing Microsoft SQL Server 2008 Exercise Guide. Database by Design

Real World Enterprise SQL Server Replication Implementations. Presented by Kun Lee

Would-be system and database administrators. PREREQUISITES: At least 6 months experience with a Windows operating system.

A basic create statement for a simple student table would look like the following.

Course Outline: Course 6317: Upgrading Your SQL Server 2000 Database Administration (DBA) Skills to SQL Server 2008 DBA Skills

Administering Windows Server 2012

Jason S Wong Sr. DBA IT Applications Manager DBA Developer Programmer M.S. Rice 88, MBA U.H. 94(MIS)

Course Syllabus. Maintaining a Microsoft SQL Server 2005 Database. At Course Completion

Explain how to prepare the hardware and other resources necessary to install SQL Server. Install SQL Server. Manage and configure SQL Server.

Database Administrator Certificate Capstone Project Evaluation Checklist

Administering Microsoft SQL Server Database (ITMT 2303)

Sai Phanindra. Summary. Experience. SQL Server, SQL DBA and MSBI SQL School saiphanindrait@gmail.com

Administering a Microsoft SQL Server 2000 Database

Administering Windows Server 2012

Course 6234A: Implementing and Maintaining Microsoft SQL Server 2008 Analysis Services

Destiny system backups white paper

Backup and Recovery by using SANWatch - Snapshot

EZManage SQL Pro. Quick guide for installation and implementation

Administering Windows Server 2012

MCTS: SQL Server 2008 Implementation and Maintenance

HP Quality Center. Upgrade Preparation Guide

Maintaining a Microsoft SQL Server 2008 Database

How To Get A Certificate From Ms.Net For A Server Server

ADMINISTERING WINDOWS SERVER 2012

Database Mirroring: High Availability (HA) and Disaster Recovery (DR) Technology

KEYWORDS InteractX, database, SQL Server, SQL Server Express, backup, maintenance.

WINDOWS AZURE SQL DATA SYNC

MS 6419 Configuring, Managing and Maintaining Windows Server 2008-based Servers

ADMINISTERING MICROSOFT SQL SERVER DATABASES

Technical Notes. EMC NetWorker Performing Backup and Recovery of SharePoint Server by using NetWorker Module for Microsoft SQL VDI Solution

MS SQL Server DBA Training Course. Table of Contents

Course 20462C: Administering Microsoft SQL Server Databases

Module 07. Log Shipping

NE-20411D Administering Windows Server 2012

Managing and Maintaining a Microsoft Windows Server 2003 Environment

Outline SSS Configuring and Troubleshooting Windows Server 2008 Active Directory

Administering Microsoft SQL Server Databases

Basic knowledge of the Microsoft Windows operating system and its core functionality Working knowledge of Transact-SQL and relational databases

Upgrading Your SQL Server 2000 Database Administration (DBA) Skills to SQL Server 2008 DBA Skills Course 6317A: Three days; Instructor-Led

SQL Server Developer Training Program. Topics Covered

SQL Server Replication Guide

Course. Overview. Length: 5 Day(s) Published: English. IT Professionals. Level: Type: Method: Delivery. Enroll now (CAL)

Backup Exec 12.5 Agent for Microsoft Virtual Servers FAQ

NE-2273B Managing and Maintaining a Microsoft Windows Server 2003 Environment

Microsoft SQL Server 2008 R2 Enterprise Edition and Microsoft SharePoint Server 2010

MIRRORING: START TO FINISH. Ryan Adams Blog - Twitter

Oracle Database 10g Express

Database Mirroring & Snapshots SQL Server 2008

Training Course SQL Server 2008 Implementation and Maintenance

Outline SSC Configuring and Troubleshooting Windows Server 2008 Active Directory

How to Copy A SQL Database SQL Server Express (Making a History Company)

COURSE 20411D: ADMINISTERING WINDOWS SERVER 2012

Computer Visions Course Outline

Administering Windows Server 2012

Upgrading Your Skills to MCSA Windows Server 2012

ACTIVE MICROSOFT CERTIFICATIONS:

This article Includes:

EASRestoreService. Manual

IP Phone Service Administration and Subscription

Course 2788A: Designing High Availability Database Solutions Using Microsoft SQL Server 2005

Symantec Enterprise Vault 10.x for File System Archiving: Administration

Integrating Data Protection Manager with StorTrends itx

Transcription:

ASPE RESOURCE SERIES Restoring Data with Database Snapshots Prepared for ASPE by Global Knowledge's Neil Tucker, MCT, MCITP, MCDBA, MCTS, MCSE Real Skills. Real Results. Real IT. in partnership with

Restoring Data with Database Snapshots Neil Tucker, MCT, MCITP, MCDBA, MCTS, MCSE Introduction What DBA wouldn t appreciate a process that allows for fast and easy restoration of lost data? If the process allows you and your users to examine the information before restoring it, to use a minimal amount of drive space, and to carry out all the necessary steps with only local resources, then you have a solution that not only saves you time, but improves the options you have for supporting users and developers. All of these options are available when using SQL Server s Database Snapshot functionality. When configured, it gives you access to a point-in-time, read-only view of the database and its records. Multiple snapshots can be created on the same database. Database snapshots require the original database to function, and you will be required to delete them before you can remove the original database. Snapshots use a copy-on-write operation that minimizes the drive space required for each snapshot. Unless there are changes in the original database, the snapshots will remain empty. Queries to the snapshot for unchanged records will automatically be redirected to the original database. Queries to the snapshot for modified records will show the data as it existed at the time of the snapshot s creation. Modified records are copied from the original database before they are changed. The copy-on-write process copies data at the page level, so some unchanged records will likely end up in the snapshot. How To Use Database Snapshots Database Snapshots require the Enterprise Edition of SQL Server and can only be created using T-SQL. The steps below show you how to do this on a test server. You will need the Enterprise or Developer editions of SQL Server 2005 or 2008. To use the scripts provided, create two folders on the root of the C: drive named Database and Snapshot. 1. Create the test database. Use the script in Figure 1 (below) to create a database named DB1 and a table named dbo.contacts with five (5) records. /* Create a new database named DB1 */ Use Master IF Exists (Select Name From sys.databases Where Name = db1 ) Drop Database DB1 Copyright 2010 Global Knowledge Training LLC. All rights reserved. 2

Create Database DB1 on Primary ( Name= DB1_Data,Filename= C:\Database\DB1.mdf ) LOG ON ( Name= DB1_log,Filename= C:\Database\DB1_log.ldf ) /* Create a table named Contacts in DB1 */ USE DB1 Create Table dbo.contacts (ID nchar(5) NOT NULL, FirstName nvarchar(50), LastName nvarchar(50), Constraint PK_Contacts Primary Key Clustered (ID Asc)) /* Insert 5 records into the Contacts Table */ Values( 101, John, Harrison ) Values( 102, Jessica, Forthwright ) Values( 103, Earl, Russell ) Values( 104, Stanley, McDonald ) Values( 105, Mary, Kellerman ) 2. Create a snapshot of DB1. Use the Figure 2 script to create a snapshot of the database. After it is created, verify that the snapshot file was created (C:\Snapshot\DB1_Snapshot.ss). Notice that no log file is needed. This is a read-only version of DB1 as it existed at the time it was created. In the Figure 2 script, notice that the NAME parameter points to the actual name of the database file and not the name of the database as specified in the AS SNAPSHOT OF parameter. Databases with multiple data files would, therefore, need multiple NAME parameters, one for each file. /* Create a snapshot of the DB1 database */ USE master Copyright 2010 Global Knowledge Training LLC. All rights reserved. 3

CREATE DATABASE DB1_Snapshot ON ( NAME = DB1_Data, FILENAME = C:\Snapshot\DB1_Snapshot.ss ) AS SNAPSHOT OF DB1; 3. Change records in DB1. Modify any record from the Contacts table in the DB1 database. Verify that the information in the DB1_Snapshot database is unchanged, using the script provided in Figure 3. The changes to DB1 have caused the original version of the data pages changed to be written to the DB1_Snapshot.ss file. /* Verify that the information in the snapshot and the original database are the same. */ Use DB1 /* Update the records in the Contacts table and compare it to the Snapshot version again */ Use DB1 --Insert dbo.contacts --Values( 106, Chris, Andrews ) -- Update dbo.contacts set FirstName= Jonathan where ID=101 Delete dbo.contacts where ID=102 /* Verify that the information in the snapshot and the original database are different. */ 4. Revert to the original version of the table. You can restore individual records in a table from the snapshot. Use the script in Figure 4 to see how to fix incorrect deletions or updates. Copyright 2010 Global Knowledge Training LLC. All rights reserved. 4

/* Reverse deletions and updates using information in the snapshot */ Use DB1 go Insert dbo.contacts Where ID=102 Update C Set C.FirstName = S.FirstName From DB1.dbo.Contacts C Inner Join DB1_Snapshot.dbo.Contacts S ON C.ID = S.ID Where C.ID = 101 /* Verify that the records in DB1 and the snapshot are the same */ 5. Revert to the original database. As long as the original database is still intact and online, you can restore all changes made since the snapshot. These database snapshot restores cannot be done when more than one snapshot exists. As with a normal database restore, exclusive access to the database is needed during this operation. To test this process, use Figure 3 script to create differences between both databases, then use Figure 5 to restore the entire database from the snapshot. -- Restore the DB1 database from the snapshot -- The restore operation will fail if there are other connections to the DB1 database Use Master Restore Database DB1 From Database_Snapshot = DB1_Snapshot Copyright 2010 Global Knowledge Training LLC. All rights reserved. 5

Caveats when Using Database Snapshots Like any other useful DBA tool, database snapshots can be overused or misused. Here are a few precautions to keep in mind before implementing this functionality in a production environment. Backups are still required: There is no substitute for regular, tested backups that are stored in a remote, secure location. The database snapshot requirement that the files be stored on the same server as the original database prevents them from being used in this manner. The fact that the snapshots become obsolete if the original database is lost also limits their use for this purpose. The strength of snapshots is in their ability to provide point-in-time views of your data and ad-hoc restore options. Beware of too many snapshots: Although the empty state of a new snapshot file makes their size negligible, take care when creating multiple snapshots on the same database. Theoretically, a database with 10 GB of data and 24 snapshots can suddenly and unexpectedly require up to 250 GB of drive space. The ability to quickly restore a database to how it looked at a particular hour of the day is very convenient, but if this functionality is not needed, the additional resource requirements can tax a mission-critical server beyond acceptable levels. A snapshot should only be created to meet specific administrative needs and then deleted when it is no longer necessary. Using Snapshots for Read-only Operations: The point-in-time, read-only nature of snapshots makes them a candidate for reporting or similar solutions. Using them in this way, however, limits their use as an adhoc restoration solution. Before allowing others to use your snapshots for development or business solutions, consider how this will affect the options available to you when administering your databases. Other dedicated read-only solutions, like Log Shipping might be considered. Conclusion If you decide to take advantage of Database Snapshots, keep its limitations in mind. It cannot replace your backup solution, and you must carefully consider the additional resource demands of each additional snapshot. It can, however, provide a fast and simple solution for viewing point-in-time data and restoring lost information from databases. Overall, it s a useful tool for reducing downtime and improving the availability of your databases. Learn More Learn more about how you can improve productivity, enhance efficiency, and sharpen your competitive edge. Check out the following Global Knowledge course(s): Developing and Implementing a SQL Server 2008 Database (M6232) SQL Server 2008 for Administration (M6231, M6232) For more information or to register, visit www.globalknowledge.com or call 1-800-COURSES to speak with a sales representative. Copyright 2010 Global Knowledge Training LLC. All rights reserved. 6

Our courses and enhanced, hands-on labs and exercises offer practical skills and tips that you can immediately put to use. Our expert instructors draw upon their experiences to help you understand key concepts and how to apply them to your specific work situation. Choose from our more than 1,200 courses, delivered through Classrooms, e-learning, and On-site sessions, to meet your IT and business training needs. About the Author Neil Tucker MCT, MCITP, MCDBA, MCSE, MCDST. Neil is a technical trainer, writer, and consultant with 16 years of experience in the IT industry. He has authored white papers and books on SQL Server, SharePoint, Windows Server, and Windows 7. Copyright 2010 Global Knowledge Training LLC. All rights reserved. 7