0% found this document useful (0 votes)
17 views22 pages

Mo 7

Uploaded by

Melkam dessalegn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views22 pages

Mo 7

Uploaded by

Melkam dessalegn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

Web Development and Database

Administration Level-IV
Based on March 2022, Curriculum Version II
Module Title: Database Backup and Recovery

Acronym
API ------------------------------------------------------Application Programming Interface

DBMS -------------------------------------------------- Database Management System

DVD -------------------------------------------------------Digital Versatile Disc

ECC -----------------------------------------------------Error-Correcting Code

ICT---------------------------------------------------------Information andCommunication Technology

JDBC ------------------------------------------------------Java Database Connectivity

LAN -------------------------------------------------------Local Area Network

ODBC ------------------------------------------------------Open Database Connectivity

RAID -------------------------------------------------------Redundant Array of Independent Disks

SQL ----------------------------------------------------------Structured Query Language

SSMS -------------------------------------------------------SQL Server Management Studio

WAN --------------------------------------------------------Wide Area Network


Unit one: Database Architecture
1.1. Architecture of database file system
Database architecture focuses on database design and construction for large enterprise
database systems that manage massive amounts of information for organizations.

The design of a DBMS depends on its architecture. Selecting the correct Database
Architecture helps in quick and secure access to data. It can be centralized or decentralized
or hierarchical. The architecture of a DBMS can be seen as either single tier or multi-tier.
The tiers are classified as follows:
1.1.1. Single tier architecture
The simplest of Database Architecture are 1 tier where the Client, Server, and Database all
reside on the same machine. In other word, it keeps all of the elements of an application,
including the interface, Middleware and back-end data, in one place. Developers see these
types of systems as the simplest and most direct way.
 The database is directly available to the user. It means the user can directly sit on the
DBMS and uses it.
 Any changes done here will directly be done on the database itself. It doesn't provide
a handy tool for end users.
 The 1-Tier architecture is used for development of the local application, where
programmers can directly communicate with the database for the quick response.
1.1.2. Two-tier Architecture

Page 1 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
The two-tier is based on Client Server architecture.

It is like client server application.

The direct communication takes place between client and server. There is no intermediate
between client and server.

Applications on the client end can directly communicate with the database at the server side.
For this interaction, API's like: ODBC, JDBC are used.

2 tier architecture provides added security to the DBMS as it is not exposed to the end user
directly.

A two-tier architecture is a database architecture where


1. Presentation layer runs on a client (PC, Mobile, Tablet, etc)
2. Data is stored on a Server.
1.1.3. Three-tier Architecture
A 3-tier architecture separates its tiers from each other based on the complexity of the users
and how they use the data present in the database.

The three tier architecture is the most popular DBMS architecture.

3-tier architecture has following layers;

 Database server (Data) Tier


 Application (Middle) Tier – also called business logic layer
application layer sits in the middle and acts as a mediator between the end-user and
the database.
 User (Presentation) Tier − End-users operate on this tier and they know nothing about
any existence of the database beyond this layer.
 The goal of Three-tier architecture is:
 To separate the user applications and physical database
 Proposed to support DBMS characteristics
 Program-data independence
Page 2 of 22 Ministry of Labor and Database Backup and Recovery Version -I
Skills Level IV November, 2023
Author/Copyright
 Support of multiple views of the data
 N-tier architecture: N-tier architecture would involve dividing an application into three
different tiers. These would be the Logic tier, presentation tier, and data tier.

1.2. Risks and Failure Scenario


There are many types of failures that can affect database processing. Some failures affect the
main memory only, while others involve secondary storage.

Cause of database failure

 Power Failure:-hardware failure.


 Disk Failure:-failures are due to head crashes or unreadable media, resulting in the
loss of parts of secondary storage. They are the most dangerous failures and one of
the most common causes of data loss.
 Human Error (Carelessness):-unintentional destruction of data or facilities
 Software Corruption
 Virus Infection:-Cyber-attacks are the biggest threat a company faces today and it is
imperative that the security solution performs real-time scanning. Depending on the
type of virus, it could have the ability to steal, corrupt, modify and even delete the
complete database.
 Natural Disasters:- fire, floods, earthquake, tsunami, absolutely no way to even find,
let alone recover, the data.
 Disgruntled Employees
 Hardware Failure :memory errors, disk crashes, bad disk sectors, disk full error and
so on. Hardware failure can also be attributed to design errors, poor quality control
during fabrication, overloading and wear out of mechanical parts.
 System Crash:-System crashes are due to hardware or software errors, resulting in
the loss of main memory.
 Network Failure:-Network failure can occur while using a Client-server
configuration or distributed database system where multiple database servers are
connected by common network.
Page 3 of 22 Ministry of Labor and Database Backup and Recovery Version -I
Skills Level IV November, 2023
Author/Copyright
 Sabotages:- These are failures due to international corruption or destruction of data,
hardware or users.

1.3 OHS
Occupational Health and Safety (OHS) requirements for database backup and recovery are
crucial to ensure the well-being and safety of individuals involved in managing and
maintaining databases. While OHS standards may vary by region and organization, here are
some general guidelines to consider when it comes to the occupational health and safety
aspects of database backup and recovery:

 Training and Competency


 Ergonomics

Design workstations and environments with ergonomic principles in mind to prevent


musculoskeletal issues among personnel. Ensure that seating, lighting, and computer
equipment are conducive to a healthy working environment.

 Workload Management
Monitor and manage the workload of personnel involved in database backup and recovery to
prevent stress and burnout. Encourage breaks and time away from the computer to reduce the
risk of repetitive strain injuries.

 Emergency Procedures
Establish clear emergency procedures for unexpected situations during database backup and
recovery processes. Ensure that personnel are aware of evacuation plans and procedures in
case of emergencies.

 Security Measures
 Equipment Safety
 Health Monitoring
 Documentation and Procedures
 Communication Protocols
 Regulatory Compliance
Page 4 of 22 Ministry of Labor and Database Backup and Recovery Version -I
Skills Level IV November, 2023
Author/Copyright
Unit Two: Database Backup Methods

2.1. Introduction to Backup


Backup is the process of creating a copy of data to protect against accidental or malicious
deletion, corruption, hardware failure, ransom ware attacks, and other types of data loss. Data
backups can be created locally, offsite, or both.

Restore is the process of retrieving data from a backup.

Recovery refers to the process of restoring data and


Restore and recovery times can vary widely depending on the backup format and data
recovery methods you choose.
The most common type of database backups are:
- Logical backup - backup of data is stored in a human-readable format like SQL
- Physical backup - backup contains binary data

2.2.Methods for back-up and recovery


2.2.1. Types of Backup

There are different types of backup, and each backup process works differently.
Table 2.1. Comparison of backup type
A comparison of different types of backup

Backup Full Mirror Incremental Differential


Backup 1 All data All data Selected - -
Backup 2 All data All data Selected Changes from backup 1 Changes from backup 1

Backup 3 All data All data Selected Changes from backup 2 Changes from backup 1

Backup 4 All data All data Selected Changes from backup 3 Changes from backup 1

1. Full backups

Page 5 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
The most basic and complete type of backup operation is a full backup. As the name implies,
this type of backup makes a copy of all data to a storage device, such as a disk or tape.
Incremental backups
An incremental backup operation will result in copying only the data that has changed since
the last backup operation of any type. An organization typically uses the modified time stamp
on files and compares it to the time stamp of the last backup.

2. Differential backups
A differential backup operation is similar to an incremental the first time it is performed, in
that it will copy all data changed from the previous backup.
3. Mirror backups
A mirror backup is comparable to a full backup. This backup type creates an exact copy of the source
data set, but only the latest data version is stored in the backup repository with no track of different
versions of the files.

One of the benefits of mirror backup is a fast data recovery time. It's also easy to access
individual backed up files. Mirror backup is the fastest backup method because it copies files
and folders to the destination without any compression.
One of the main drawbacks, though, is the amount of storage space required. It needs more storage
space than any other backup type; password protection is not possible and cannot track different
versions of files

3-2-1 rule

Determining appropriate methods

To determine the type of backup strategy to be used there are different determinant factors
such as overall business cost, performance, data protection levels, total amount of data
retained and availability goals.

An organization often uses one of the following backup settings:

 Full daily

Page 6 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
 Full weekly + differential daily

 Full weekly + incremental daily

2.3. Range of back-up and restoration


While each approach carries its own benefits and risks, organizations need to consider their
need for performance, data protection, their total volume of data assets, and the cost of
recovery. The following five factors can be used in making a decision about which backup
schedule is right for you.

 How active are your read/write activities?


 What is your tolerance for recovery time?
 How many of your data assets are actively being update?
 How much storage space can you dedicate?
 How much data do you have?
Table 2.1. Comparison of backup type

2.4. Off-line back-ups


Off-line backup is also called cold backup or static backup. It is a database backup during
which the database is offline and not accessible to update or the database operations are
entirely stopped, and then the backup is performed. While the backup is in progress, no
business operations can be performed.

Page 7 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
Cold backups consume fewer resources but have a limitation. The database cannot be
accessed when the backup operation is in progress.

The advantage of this method is that users are still able to access the system during the
backup.

2.5. On-line file back-ups


It is also called a hot backup or dynamic backup. A hot backup is a backup performed while
the database is open and available for use (read and write activity). It is performed in near
real-time when the systems are up and running, and new data is continuously generated or
captured.

2.6.Disk mirroring
Disk mirroring, also known as RAID 1, is the replication of data to two or more disks.

Page 8 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
2.7. RAID
RAID refers to redundancy array of the independent disk. It is a technology which is used to
connect multiple secondary storage devices for increased performance, data redundancy or
both
There are 7 levels of RAID schemes. These schemas are as RAID 0, RAID 1, ...., RAID 6.
These levels contain the following characteristics:
- It contains a set of physical disk drives.
- The operating system views these separate disks as a single logical disk.
- In this technology, data is distributed across the physical drives of the array.
- Redundancy disk capacity is used to store parity information.
- In case of disk failure, the parity information can be helped to recover the data.

2.8. Off-site back-up files

Offsite backup is the replication of the data to a server which is separated geographically
from a production systems site. Offsite data backup may also be done via direct access, over
Wide Area Network (WAN).
An offsite backup is a backup process or facility that stores backup data or applications
external to the organization or core IT environment..
Offsite backups are primarily is used in data backup and disaster-recovery measures.

 Advantages and disadvantages Offsite Storage


Advantages

 Scalability:.
 Cost & Value:
 Fast Deployment
 Managed Storage Service:
 Connectivity
 Performance
 Disadvantages

Page 9 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
 It can be difficult to access
 Security and Privacy:
 Compliance and Data Governance
 Lifetime Costs:
 Speed:.

2.9. Onsite Backup


In onsite storage, data and storage hardware are geographically located internally to your
business or organization. You may have a computer room or data center onsite where the
storage arrays are securely located. All your internal systems will have direct access to the
storage within the same building or organization, usually over an internal Local Area
Network (LAN).

 Advantages of onsite storage:


 Immediate access to data
 Less expensive
 Internet access not needed
 Control of your own data security
 Performance improvement
 Disadvantage of onsite storage;
- In the event of a catastrophic event, onsite data storage can be destroyed.
- Storage can be extremely expensive depending on the size of the storage array.
- Storage device will need to be managed, maintained, and upgraded in-house.

2.10. Hybrid storage


Hybrid storage is a mix of offsite and onsite storage approaches. A typical hybrid setup
could be a local storage array at a head office which replicates data to an external cloud-
based location; such a setup could be for backups or data integrity reasons.

Self-check 2
Part-I multiple choice

Page 10 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
1. Backing up the data to a server which is geographically separated from a production
systems.
A. Online B. Offline C. Offsite D. Onsite
2. A mix of offsite and onsite storage approaches for the benefit of completeness.
A. Dynamic B. Hybrid C. Cloud D. Cold
3. One is not the advantages of onsite backup
A. May be destroyed during a catastrophic event C. Control of your own data
security
B. Immediate access to data D. Less expensive
4. Which RAID level is called a mirroring of data?
A.RAID 0 B. RAID 1 C. RAID 2 D. RAID 7 E. All level
5. How many disk drives are required to implement disk mirroring?
A. At least two physical drives.
B. At least one disk drive and two logical drives
C. At least two logical drives
D. None
6. Which one of the following statement is incorrect about RAID?
B. It contains a set of physical disk drives.
C. The operating system views these separate disks as a single logical disk.
D. Data is distributed across the physical drives of the array.
E. None
Part-II Give short answer

1. List and explain Types of backup?


2. Write the difference between hot and cold backup?
3. List the Advantages and Dis advantages of Full backup

Operation sheet 2.1 Take backup


Operation title: Take backup
Page 11 of 22 Ministry of Labor and Database Backup and Recovery Version -I
Skills Level IV November, 2023
Author/Copyright
Purpose: Take database Backup Using SSMS

Tools and equipment: SQL server installed computer

Steps by doing tasks:


1. Open SQL Server 2008
2. Connect the Server and point to your database
3. Make right click on your database and Select
Task click on Backup

4. Select the backup destination and write the backup name(Add)

Page 12 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
5. Click on OK button

6. Click on OK button

Page 13 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
Operation sheet 2.2 Taking Database Offline
Operation title: Taking Database Offline

Purpose: Taking Database Offline using SSMS (SQL Server Management Studio) and T-
SQL

Tools and Equipment: computer and SQL server

Steps by doing tasks:

1. Login to SQL Server Management Studio.


2. In the Object Explorer, select the database you want to take offline and right-click.
3. In the right-click menu go to Tasks >> Take Offline.
4. In the pop-up window, choose the check box under the Drop All Active
Connections and click OK

5. After Opening SQL Server Management Studio and open a Query Editor pane.
Enter and execute the following code:
USE DB_name;

GO

ALTER DATABASE <<Database-name>> SET OFFLINE

Page 14 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
Operation sheet 2.3 Take Full backup
Operation title: Take Full backup

Purpose: Back Up the Database Using T-SQL

Tools And Equipment: computer and SQL server

Steps by doing tasks:

1. After Opening SQL Server Management Studio and open a Query Editor pane. Enter and
execute the following code:
BACKUP DATABASE << databaseName >> TO DISK = 'C:\Backupname.BAK'

The command is BACKUP DATABASE databaseName. The "TO DISK" option specifies that the
backup should be written to disk and the location and filename to create the backup is specified.

2. Create a full SQL Server backup with a password


BACKUP DATABASE << databaseName >>
TO DISK = 'C:\ Backupname.BAK'
WITH PASSWORD = 'Q!W@E#R$'
GO

Page 15 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
Unit Three: Database Recovery Points & Procedures

3.1.Database recovery point


Database recovery is the process of restoring the database to a correct (consistent) state in the
event of a failure.

An operating system crash can terminate the DBMS processes

 The DBMS can crash


 System failure(e.g. power outage)
 Media failures(e.g. Head crash on the disk)

 The system might lose power

 Human error can result in deletion of critical data.

 When a DBMS recovers from a crash, it should maintain the following

- It should check the states of all the transactions, which were being executed.

- A transaction may be in the middle of some operation; the DBMS must ensure the
atomicity of the transaction in this case.

- It should check whether the transaction can be completed now or it needs to be rolled
back.

- No transactions would be allowed to leave the DBMS in an inconsistent state.

3.1.1. Database Recovery Techniques


 For fast restoration or recovery of data, the database must hold tools which recover the
data efficiently.

 So, recovery techniques which are based on deferred update and immediate update or
backing up data can be used to stop loss in the database.
Page 16 of 22 Ministry of Labor and Database Backup and Recovery Version -I
Skills Level IV November, 2023
Author/Copyright
 Immediate Update: As soon as a data item is modified in cache, the disk copy is
updated.

 Deferred Update: All modified data items in the cache are written either after a
transaction ends its execution or after a fixed number of transactions have completed
their execution.

 Shadow update: The modified version of a data item does not overwrite its disk copy
but is written at a separate disk location.

 In-place update: The disk version of the data item is overwritten by the cache version.

3.1.2. Two approaches of Recovery


 Manual Reprocessing

In a Manual Reprocessing recovery approach, the database is periodically backed up (a


database save) and all transactions applied since the last save are recorded

If the system crashes, the latest database backup set is restored and all of the transactions are
re-applied (by users) to bring the database back up to the point just before the crash.

 Several shortcomings to the Manual Reprocessing approach:


 Time required to re-apply transactions

 Transactions might have other (physical) consequences

 Re-applying concurrent transactions in the same original sequence may not be


possible.

 Automated Recovery with Rollback / Roll forward


 The Automated Recovery process uses both rollback and roll forward to restore the
database.

Page 17 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
 Rollback: Undo any partially completed transactions (ones in progress when
the crash occurred) by applying the before images to the database. UNDO
the transactions in progress at the time of failure.
 Roll forward: Redo the transactions by applying the after images to the
database. This is done for transactions that were committed before the crash.
REDO the transactions that successfully complete but did not write to the
physical disk.
 Checkpoint is a mechanism where all the previous logs are removed from
the system and stored permanently in a storage disk. Checkpoint declares a
point before which the DBMS was in consistent state, and all the
transactions were committed. Checkpoints can also be taken (less time
consuming) in between database saves.
 Database can be recovered from the last checkpoint in much less time.

3.2.Testing restore process


Test Database recovery testing is used to ensure that the database is recovered.
The key aim of backup testing is to ensure the business can retrieve its data and continue
operations.

 Common Steps in Database Backup and Recovery Testing


In database recovery testing, you need to run the test in the actual environment to check if the
system or the data can actually be recovered in case of any disasters and any other unforeseen
events in the business environment.
 The common actions performed in Database Recovery Testing:
 Testing of database system
 Testing of the SQL files
 Testing of partial files
 Testing of data backup
 Testing of Backup tool
 Testing log backups

Page 18 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
These policies should set out the recovery point objective (RPO) and the recovery time
objective (RTO).
The RPO sets out how old the most recent backup can be, or put another way, the amount of
data loss the organization can tolerate and still operate.

The RTO specifies how quickly systems must be recovered. Unless the business tests
recovery, CIOs will not know if they can meet the RTO and RPO, or if recovery works at all.

3.3.Restore a database to a point in time


A point-in-time recovery can be used to return the database data and database object to its
functional state prior to detrimental action has been performed.

The database must be in either the Full or Bulk-Logged recovery model.

3.3.1. Restore a database using T-SQL


 Restore full backup and one transaction log backup

The first command does the restore and leaves the database in a restoring state and second
command restores the transaction log backup and then makes the database useable.
RESTORE DATABASE <<DatabaseName>>FROM DISK = 'C:\BackupName.BAK'
WITH NORECOVERY
GO
RESTORE LOG <<DatabaseName>> FROM DISK = 'C:\BackupName.TRN'
WITH RECOVERY
GO

 Restore full backup and two transaction log backups

This restores the first two backups using NORECOVERY and then RECOVERY for the last
restore.
RESTORE DATABASE <<DatabaseName>> FROM DISK = 'C:\ BackupName.BAK'
WITH NORECOVERY

Page 19 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright
GO
RESTORE LOG <<DatabaseName>> FROM DISK = 'C:\ BackupName.TRN'
WITH NORECOVERY
GO
RESTORE LOG <<DatabaseName>> FROM DISK = 'C:\ BackupName1.TRN'
WITH RECOVERY
GO

 Restore full backup, latest differential and two transaction log backups

This restores the first three backups using NORECOVERY and then RECOVERY for the
last restore.
RESTORE DATABASE <<DatabaseName>> FROM DISK = 'C:\ BackupName.BAK'
WITH NORECOVERY
GO
RESTORE DATABASE <<DatabaseName>> FROM DISK = 'C:\ BackupName.DIF'
WITH NORECOVERY
GO
RESTORE LOG <<Database Name>> FROM DISK = 'C:\ BackupName.TRN'
WITH NORECOVERY
GO
RESTORE LOG <<DatabaseName>> FROM DISK = 'C:\ BackupName1.TRN'
WITH RECOVERY
GO

Self-check 3
Part-I multiple choice

1. _______________the process of restoring the database to the consistent state in the


event of a failure.
A. Restore B. Attach C. Recovery D. All
Page 20 of 22 Ministry of Labor and Database Backup and Recovery Version -I
Skills Level IV November, 2023
Author/Copyright
2. A process by which DBMS REDO the transactions that successfully complete before
failure but did not write to the physical disk.
B. Recover B. Roll Forward C. Rollback D. Restore
3. A recovery method by which the modified version of a data item is written at a separate
disk location.
A. Differed Update
B. Shadow update
C. Immediate update
D. None
4. Factors that enforce the transaction not to reach a commit or abort point.
A. Human error
B. operating system crash
C. DBMS crash

D. All
Part-II Give short Answer

1. Write and explain recovery approaches


2. Explain Rollback and commit

Page 21 of 22 Ministry of Labor and Database Backup and Recovery Version -I


Skills Level IV November, 2023
Author/Copyright

You might also like