You are on page 1of 16

SQL Server Database

Restore
SAKETH
SOORAM
Overview
Introduction to backup and restore
Complete Database Restores-Recovery Models
Types of restores in simple recovery model
Simple Recovery Model in detail


Introduction
The SQL Server backup and restore component provides an essential safeguard for protecting
critical data stored in your SQL Server databases.
To minimize the risk of catastrophic data loss, back up of databases should be made to preserve
modifications to the data on a regular basis.
A well-planned backup and restore strategy helps protect databases against data loss caused by
a variety of failures.

Complete Database Restores-
Models
Two types of Recovery models:
Simple Recovery Model
Full Recovery Model

In a complete database restore, the goal is to restore the whole database.
The whole database is offline for the duration of the restore.
Before any part of the database can come online, all data is recovered to a consistent point in which all
parts of the database are at the same point in time and no uncommitted transactions exist.
Full Recovery Model
Under the full recovery model, after data backup or backups are restored, all subsequent
transaction log backups must be restored and then the database should be recovered.
Database can be restored to a specific recovery point within one of these log backups.
The recovery point can be a specific date and time, a marked transaction, or a log sequence
number (LSN).

Simple Recovery Model
Under the simple recovery model, the database cannot be restored to a specific point in time
within a specific backup.
A full database restore under the simple recovery model involves one or
two RESTORE statements, depending on whether a differential database backup is restored or
full database backup.
If a full database backup is used, the most recent backup is restored.
If a differential database backup is used, the most recent full database backup is restored
without recovering the database, and then the most recent differential database backup is
restored and the database is recovered.

Types of recovery
Transact-SQL
SQL Server Management Studio
Restore to New Location

Basic Transact-SQL Restore
Full database backup restore:
RESTORE DATABASE database_name FROM backup_device WITH RECOVERY

Differential Database Backup:
RESTORE DATABASE database_name FROM backup_device [ WITH NORECOVERY ]

Full Database Backup
Differential Database Backup
USE master;
--Make sure the database is using the simple recovery model.
ALTER DATABASE Northwind2 SET RECOVERY SIMPLE;
GO
-- Back up the full Northwind2 database.
BACKUP DATABASE Northwind2
TO DISK = C:\SQLServerBackups\Northwind2_1.bak'
WITH FORMAT;
GO
Using SQL Code

--Create a differential database backup.
BACKUP DATABASE Northwind2
TO DISK = ' C :\SQLServerBackups\Northwind2_2.bak'
WITH DIFFERENTIAL;
GO
--Restore the full database backup (from backup set 1).
RESTORE DATABASE Northwind2
FROM DISK = ' C :\SQLServerBackups\Northwind2_1.bak'
WITH FILE=1, NORECOVERY;

--Restore the differential backup (from backup set 2).
RESTORE DATABASE Northwind2
FROM DISK = ' C :\SQLServerBackups\Northwind2_2.bak'
WITH FILE=2, RECOVERY;
GO

SQL Server Management Studio


DEMO



THANK YOU

You might also like