You are on page 1of 34

7/23/2019 Print content

Administering Microsoft SQL Server 2012 Databases

Configure and Maintain a Backup Strategy

Introduction
Managing Backups
Restoring Databases
Summary

Introduction
The Configure and Maintain a Backup Strategy module provides you with the
instruction and server hardware to develop your hands on skills in the defined topics.
This module includes the following exercises:

Managing Backups
Restoring Databases

Lab Diagram

During your session you will have access to the following lab configuration. Depending
on the exercises you may or may not use all of the devices, but they are shown here in the
layout to get an overall understanding of the topology of the lab.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 1/34
7/23/2019 Print content

Connecting to your lab

In this module you will be working on the following equipment to carry out the steps
defined in each exercise.

PLABSQL01 (SQL Server 1)

To start, simply choose a device and click Power on. In some cases, the devices may
power on automatically.

For further information and technical support, please see our Help and Support
page.

Copyright Notice
This document and its content is copyright of Practice-IT - © Practice-IT 2014. All rights reserved. Any
redistribution or reproduction of part or all of the contents in any form is prohibited other than the
following:
1) You may print or download to a local hard disk extracts for your personal and non-commercial use
only.
2) You may copy the content to individual third parties for their personal use, but only if you
acknowledge the website as the source of the material. You may not, except with our express written
permission, distribute or commercially exploit the content. Nor may you transmit it or store it in any
other website or other form of electronic retrieval system.

Exercise 1 - Managing Backups


In this exercise, you will perform the tasks required to configure and maintain a backup
strategy. To better understand these tasks, please refer to your course material or visit
http://technet.microsoft.com/en-us/library/ms187048.aspx to gain an understanding of
this topic.

In this exercise, you will learn the following about Microsoft SQL Server 2012:

Different backup models, including point-in-time recovery


Protecting customer data even if backup media is lost

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 2/34
7/23/2019 Print content

Performing backup/restore based on proper strategies including backup redundancy


Implementing and testing a database implementation and backup strategy
Backing up an SQL Server environment
Backing up a system database

Understanding Different Backup Models

When backing up SQL databases, you can use different types of backup methods. The
type of backup mechanism you choose depends on your need, the frequency of the
backup, and the criticality of data. Here are some of the backup methods that you can
use:

Full database backup: In this backup method, everything is backed up - including


database objects, system tables, and the data. When the backup is being taken, if
there are changes to the database through various transactions, the changes are also
backed up. The benefit of this backup method is that you can restore the backup to
the point when the backup was performed.
Differential backup: In this method, only the changes that were made to the
database since the last backup are backed up. This type of backup is done in
conjunction with the full database backup.
Transaction log backup: In this method, the transaction log is backed up. The
changes of the last transaction log backup are recorded and then transactions from
the log that have been either committed or cancelled are removed. This method uses
incremental backup, which means that you will require full database backup and all
transaction log backups for restoration.
File and file group backup: In this method, the individual database files and its file
groups are backed up. You must also back up the transaction log.
Copy-only backup: In this method, you back up the full database and the transaction
log files. However, the order in which you perform the backup is not critical. This
method creates afull backup of the transaction logs and the database.

SQL Server supports three recovery models. These are:

Simple: In this method, most of the recent database can be recovered. However, no
point-in-time recovery can be performed.
Full: This method requires full database and transaction log backups. Using the
transaction logs, you can perform point-in-time recovery. You can also recover only
to the time when the full backup was performed.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 3/34
7/23/2019 Print content

Bulk-logged: This method minimizes the transaction log activity during the bulk
operations and, therefore, does not support point-in-time recovery.

Protecting Customer Data

You can use passwords to protect the media on which customer data is stored. The
password can be used to protect the data:

During restoration of databases


During append operations to the media
While overwriting the media

Even though the passwords do not provide a strong protection mechanism, they can
certainly deter unauthorized users from accessing the data.

Backup an SQL Server Environment

In an SQL Server environment, the term "backing up" means backing up the databases
and transaction logs that exist on the SQL server.

To back up an SQL Server environment, perform the following steps:

Step 1
Ensure you have powered on the required devices and Connect to PLABSQL01.

From the desktop, double-click SQL Server Management Studio.

The Connect to Server dialog box is displayed.

Keep the default settings and click Connect.

The Microsoft SQL Server Management Studio opens.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 4/34
7/23/2019 Print content

In Object Explorer, expand Databases, right-click AdventureWorks2012, select


Tasks, and then select Back Up.

The Back Up Database - AdventureWorks2012 dialog box is displayed.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 5/34
7/23/2019 Print content

Click OK to initiate the backup.

After the backup is complete, the Microsoft SQL Server Management Studio dialog
box is displayed. Click OK to close the dialog box.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 6/34
7/23/2019 Print content

Perform Backup/Restore Based on Proper Strategies

To back up / restore based on proper strategies, including backup redundancy, perform


the following steps:

Step 1
From SQL Server Management Studio.

In Object Explorer, expand Databases, right-click AdventureWorks2012, select


Tasks, and then select Back Up.

The Back Up Database - AdventureWorks2012 dialog box is displayed.

Note: In the previous task, you performed a full backup. In this task, you should perform
a differential backup and then perform a restore.

In Backup type, select Differential.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 7/34
7/23/2019 Print content

Keep the remaining settings as the default settings and click OK.

The Microsoft SQL Server Management Studio dialog box is displayed. Click OK
to close the dialog box.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 8/34
7/23/2019 Print content

Note: In Backup sets to restore, AdventureWorks2012 - Full Database


Backup is selected.

After backing up the database, now you will restore the database. To restore the database,
right-click AdventureWorks2012, select Tasks, select Restore and then select
Database.

The Restore Database - AdventureWorks2012 dialog box is displayed.

In the Destination drop-down list, enter AdventureWorks2012.

In the left pane, select Options and select Overwrite the existing database.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 9/34
7/23/2019 Print content

In the Server connections section, select Close existing connections to the


destination database and click OK.

It may take a few minutes to a few hours to restore a database - depending on what the
size of the database is. After the restore is successful, the Microsoft SQL Server
Management Studio dialog box is displayed. Click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 10/34
7/23/2019 Print content

You are navigated back to Microsoft SQL Server Management Studio.

Creating redundant backup sets

You can create redundant backup media sets using the command line. Here is a sample
script that can help you create redundant media sets:

BACKUP DATABASE AdventureWorks2012

TO TAPE = '\\.\tape0', TAPE = '\\.\tape1'

MIRROR TO TAPE = '\\.\tape2', TAPE = '\\.\tape3'

WITH

FORMAT,

MEDIANAME = 'AdventureWorks2012Backup';

GO

In this script, you can define the first set of backup media in the TO TAPE syntax. The
redundant media set needs to be defined in the MIRROR TO TAPE syntax.

Backup the System Database


https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 11/34
7/23/2019 Print content

You typically do not back up system databases at regular intervals. This is because you do
not alter the system databases. The transaction logs are also not backed up and,
therefore, you can use the Simple recovery method.

To back up the system database, perform the following steps:

Step 1
From SQL Server Management Studio.

In Object Explorer, expand Databases, expand System Databases, right-click


Master, select Tasks, and then select Back Up.

The Back Up Database - master dialog box is displayed.

Note that the Recovery model field is automatically set to SIMPLE. For the purpose of
this lab, review and keep the default settings.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 12/34
7/23/2019 Print content

In the left pane, click Options. You can select various overwrite media options on the
Options tab. You can also configure reliability. For the purpose of this lab, review the
settings, keep the default settings, and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 13/34
7/23/2019 Print content

The Microsoft SQL Server Management Studio dialog box is displayed. Click OK
to close the dialog box.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 14/34
7/23/2019 Print content

Leave the devices you have powered on in their current state and proceed to the next
exercise.

Exercise 2 - Restoring Databases


In this exercise, you will perform the tasks required to restore databases. To better
understand these tasks, please refer to your course material or visit
http://msdn.microsoft.com/en-us/library/ms191253.aspx to gain an understanding of
this topic.

In this exercise, you will learn the following about Microsoft SQL Server 2012:

Restoring a database secured with TDE


Recovering data from a damaged database
Restoring to point-in-time
Performing a filegroup restore
Performing a page-level restore
https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 15/34
7/23/2019 Print content

Restoring a Database Secured with TDE

You can have databases that are encrypted using Transparent Data Encryption (TDE).
You can restore a TDE-encrypted database only if you have the certificate and the private
keys. Therefore, if you are backing up a TDE-encrypted database, you also back up the
certificate and the Database Encryption Key (DEK).

If you do not have the certificate available when you want to restore the encrypted
database, you will first have to re-create the database using the backup of the original
certificate. After you re-create the certificate, you will be able to restore the database.

Note that you can still use the certificate that has expired for encrypting and decrypting
the database with TDE.

Recovering Data from a Damaged Database

Note: Before performing this task, ensure that you have backed up the model database
with FULL recovery.

To recover data from a damaged database, perform the following steps:

Step 1
Ensure you have powered on the required devices and Connect to PLABSQL01.

On the desktop, double-click SQL Server Management Studio.

The Connect to Server dialog box is displayed.

Keep the default settings and click Connect.

Microsoft SQL Server Management Studio opens.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 16/34
7/23/2019 Print content

In Object Explorer, expand Databases, expand System Databases, right-click


model, select Tasks, select Restore, and then select Page.

The Restore Page - model dialog box is displayed.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 17/34
7/23/2019 Print content

Click Check Database Pages. Note that the Done message appears in the Progress
section of the left pane. However, there are no pages listed in the Pages section. This
means that there are no corrupt pages.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 18/34
7/23/2019 Print content

Click Cancel to close the Restore Page - model dialog box.

Restoring to Point-in-time

Point-in-time recovery can be performed only with the database that uses the Full
recovery model. Point-in-time recovery means that you can recover data from the most
recent committed transaction with the condition that you have the updated transaction
log available.

To restore to point-in-time, perform the following steps:

Step 1
From SQL Server Management Studio.

In Object Explorer, expand Databases, right-click AdventureWorks2012, select


Tasks, select Restore, and then select Database.

The Restore Database - AdventureWorks2012 dialog box is displayed.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 19/34
7/23/2019 Print content

This will perform a point-in-time restore. However, if you choose not to perform point-
in-time restore, then you should click Timeline in the Destination section and select
the time from which you want to restore the database.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 20/34
7/23/2019 Print content

However, this task focuses on point-in-time and, therefore, you need to close the
Backup Timeline: AdventureWorks2012 dialog box and go back to the Restore
Database - AdventureWorks2012 dialog box.

In the left pane, click Options.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 21/34
7/23/2019 Print content

In the Restore Options section, select Overwrite the existing database (WITH
REPLACE).

Note: Since you are restoring on the same instance, you will need to overwrite the
existing database and ensure all server connections are closed.

In the Server connections section, select Close existing connections to


destination database and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 22/34
7/23/2019 Print content

The restoration process starts. After it completes, the Microsoft SQL Server
Management Studio dialog box is displayed. Click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 23/34
7/23/2019 Print content

The point-in-time restore is successful.

Performing a File Group Restore

File and file group restore can be performed if a database uses the full or bulk-logged
recovery model. When either of the recovery models is used, you can perform a file
restore and need not restore the entire database to restore the file and file group.

To perform a file group restore, perform the following steps:

Step 1
From SQL Server Management Studio.

In Object Explorer, expand Databases, right-click AdventureWorks2012, select


Tasks, select Restore, and then select File and Filegroups.

Note: Before performing the restore, ensure you have performed a full backup.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 24/34
7/23/2019 Print content

The Restore File and Filegroups - AdventureWorks2012 dialog box is displayed.

In the Select the backup sets to restore section, select Restore.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 25/34
7/23/2019 Print content

In the left pane, click Options.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 26/34
7/23/2019 Print content

In the Restore Options section, select Overwrite the existing database (WITH
REPLACE) and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 27/34
7/23/2019 Print content

The Microsoft SQL Server Management Studio dialog box is displayed. Click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 28/34
7/23/2019 Print content

Performing a Page-level restore

Page-level restores are typically performed when you figure out there are a number of
damaged pages in a database. You need to replace the damaged pages and, therefore, you
will need to restore pages from a backed up database. It is important to note that if
damaged pages are recurring too often in your database, then it is advisable to check the
volume on which the database is stored. To be able to perform page-level restore, you
need to have a backup database with the full or bulklogged recovery model.

Note: Before performing this task, ensure that you have backed up the model database
with FULL recovery.

To perform a page-level restore, perform the following steps:

Step 1
From SQL Server Management Studio.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 29/34
7/23/2019 Print content

In Object Explorer, expand Databases, expand System Databases, right-click


model, select Tasks, select Restore, and then select Page.

The Restore Page - model dialog box is displayed.

In the Pages section, click Add. Note that a blank row appears under the File ID and
Page ID columns.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 30/34
7/23/2019 Print content

Click in the blank column under File ID and enter 1. Click in the blank column under
Page ID and click 10. Click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 31/34
7/23/2019 Print content

The Microsoft SQL Server Management Studio dialog box is displayed. Click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 32/34
7/23/2019 Print content

Shutdown all virtual machines used in this lab, by using the power functions located in
the Tools bar before proceeding to the next module. Alternatively you can log out of the
lab platform.

Summary
In this exercise, you learnt the following about Microsoft SQL Server 2012:

Different backup models, including point-in-time recovery


Protecting customer data even if backup media is lost
Performing backup/restore based on proper strategies, including backup
redundancy
Implementing and testing a database implementation and backup strategy
Backing up an SQL Server environment
Backing up a system database
Restoring a database secured with TDE

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 33/34
7/23/2019 Print content

Recovering data from a damaged DB


Restoring to point-in-time
Performing a filegroup restore
Performing a page-level restore

Also try
Using the current lab setup, you can perform the following tasks at your own pace.

Performing a system database backup while overwriting any existing backup


Creating a redundant backup in tapes
Performing backup of AdventureWorks2012 database and setting the expiration
date to one week later

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 34/34

You might also like