You are on page 1of 19

• Database Backup and

s
Recovery
Learning Objectives
• At the end of this topics the students able to
Understand the importance of backup and
recovery
Difference between backup and recovery
 Identify the back methods and recovery
Learn the different types of recovery
Introduction
• People are advised to take backup of their
important data from the hard drive and then use
removable storage media devices. like flash
drive, memory card, CD/DVD etc to store the
backup file.
• This can help people in making data available in
future even if the hard drive has replaced or any
hardware equipments become failing.

Complied by muluken ashagre


• Backup and recovery is the set of concepts,
procedures, and strategies involved in protecting
the database against data loss caused by media
failure or users errors.
• In general, the purpose of a backup and recovery
strategy is to protect the database against data
loss and reconstruct lost data.
• Data can be lost as a result of many different
problems such as:

Complied by muluken ashagre


 Hardware failures
 Viruses
 Incorrect use of UPDATE and DELETE
statements
 Software bugs
 Disasters, such as fire or flood
• To prevent data loss, you can implement a backup
and recovery strategy for your databases.
• This topic explains the database backup and
recovery techniques.

Complied by muluken ashagre


• Methods of Database Backup
• Database backup is the process of dumping
data (from a database, a transaction log, or a
file) into backup devices that system creates
and maintains.
• A backup device can be a disk file or a tape.
• Database Engine provides both static and
dynamic ways to take backups.

Complied by muluken ashagre


 Static backup means that during the backup
process, the only active session supported by
the system is the one that creates the backup.
 In other words, user processes are not allowed
during backup.
Dynamic backup means that a database backup
can be performed without stopping the database
server, removing users, or even closing the files.
(The users will not even know that the backup
process is in progress.)

Complied by muluken ashagre


• Database Engine provides four different backup
methods.
• They are:
1. Full database backup
2. Differential backup
3. Transaction log backup
4. File (or file group) backup

Complied by muluken ashagre


• Performing Backup
 You can perform backup operations using SQL server
management studio.
 All types of backup operations can be executed using two
Transact-SQL statements:
BACKUP DATABASE
BACKUP LOG
 Database engine allows you to back up databases,
transaction logs, and files to the following backup
devices:
o Disk
o Tape

Complied by muluken ashagre


• Disk files: are the most common media used for
storing backups. Disk backup devices can be
located on a server’s local hard disk or on a
remote disk on a shared network resource.
• Tape backup devices are generally used in the
same way as disk devices. However, when you
back up to a tape, the tape drive must be attached
locally to the system.

Complied by muluken ashagre


Syntax for database backup
• It is possible to Backup database in a single
line code
• The Syntax for database backup
backup database database_name to disk
=‘disk_name\DBS name.bac ‘;
Example:
• backup database assignement to
disk=‘e:\assi.bak';
Complied by muluken ashagre
To see the contents of assignment Database
• use assignment;
• select *from cours;
• select *from instructor;
• select *from student;
To take up backup of assignment Database
backup database assignment to disk='e:\assi.bak';
use master;
drop database assignment;
Database Recovery

 Database Recovery is the process of reconstructing


the database after any kind of data loss.
 A major responsibility of the database administrator is
to prepare for the possibility of hardware, software,
network,process, or system failure.
 If such a failure affects the operation of a database
system, you must usually recover the database and
return to normal operation as quickly as possible.
Recovery

Complied by muluken ashagre


Cont…
 Database Recovery should protect the
database and associated users from unnecessary
problems and avoid or reduce the possibility of
having to duplicate work manually.
Syntax for database recovery

• It is possible to Recover database in a single line


code
• The Syntax for database Recovery
• Restore database database_name from
disk=‘disk_name\DBS name.bac‘;

• Restore database infolink from disk='d:/xx.bak';


• Restore database assignment from disk='e:\assi.bak';
Stapes to take LDF and MDF file(detaching)

• Go to start
• Type service
• Make it stop sql service
• Go to local disk c
• Program file(x86)
• Microsoft SQL Server
• MSSQL10_50.MSSQLSERVER
• MSSQL
• Data
• Copy the MDF and LDF file you want
Stapes to attach Database
• Right click on Database
• Click to attach
• Click to add
• Go to the destination you put LDF and MDF
file
• Select mdf file then
• Click to ok
• Click to ok
Activities/exercise
1. What is a backup mean?
2. Describe the use of backup and
recovery?
3. Briefly identify the backup Medias.
4. What causes data loss?

Complied by muluken ashagre

You might also like