TM07 Database Backup and Recovery
TM07 Database Backup and Recovery
TM07 Database Backup and Recovery
Administration
Level-IV
Based on March 2022, Curriculum Version II
November, 2023
Addis Ababa, Ethiopia
Tabel of content
Tabel of content ..................................................................................................................................... 0
Acknowledgment .......................................................................................................................................... 1
Acronym ........................................................................................................................................................ 2
Introduction to the Module ................................................................................................................. 3
1.1. Architecture of database file system ............................................................................................ 5
1.2. Risks and Failure Scenario ............................................................................................................. 8
1.3 OHS.............................................................................................................................................. 11
2.1. Introduction to Backup ............................................................................................................... 14
2.2. Methods for back-up and recovery ............................................................................................ 14
2.3. Range of back-up and restoration .............................................................................................. 19
2.4. Off-line back-ups ......................................................................................................................... 22
2.5. On-line file back-ups ................................................................................................................... 22
2.6. Disk mirroring.............................................................................................................................. 24
2.7. RAID............................................................................................................................................. 24
2.8. Off-site back-up files ................................................................................................................... 28
2.9. Onsite Backup ............................................................................................................................. 30
2.10. Hybrid storage ......................................................................................................................... 31
Self-check 2 ................................................................................................................................................. 32
Operation sheet 2.1 Take backup ............................................................................................................... 33
Operation title: Take backup .................................................................................................................. 33
Operation sheet 2.2 Taking Database Offline ............................................................................................. 35
Operation sheet 2.3 Take Full backup ........................................................................................................ 36
LAP Tests ..................................................................................................................................................... 37
Unit Three: Database Recovery Points & Procedures............................................................................... 38
3.1. Database recovery point ............................................................................................................. 39
3.2. Testing restore process ............................................................................................................... 43
3.3. Restore a database to a point in time......................................................................................... 44
Self-check 3 ................................................................................................................................................. 47
Operation sheet 3.1 .................................................................................................................................... 48
LAP Test....................................................................................................................................................... 50
References .................................................................................................................................................. 51
Developer’s Profile ...................................................................................................................................... 56
Acknowledgment
Ministry of Labor and Skills wish to extend thanks and appreciation to the many representatives
of TVET instructors and respective industry experts who donated their time and expertise to the
development of this Teaching, Training and Learning Materials (TTLM).
The module "Complete Database Backup and Recovery" addresses the critical aspects of
safeguarding and restoring databases, ensuring the continuity of valuable information systems.
This module covers the units:
Database Architecture
Database Backup Methods
Database Recovery Points & Procedures
Learning Objective of the Module
At the end of the module the trainee will be able to:
Identify and comprehend the file system architecture of a database.
Recognize potential risks and failure scenarios associated with the database.
Execute online file backups following organizational standards.
Utilize advanced techniques such as disk mirroring and RAID configurations.
Determine strategic recovery points based on backup arrangements and organizational
guidelines.
Module Instruction
For effective use these modules trainees are expected to follow the following module
instruction:
1. Read the specific objectives of this Learning Guide.
2. Follow the instructions described below.
3. Read this Learning Guide and understand it, and then do in practical.
4. Accomplish the “Self-check”.
5. If you earned a satisfactory evaluation from the “Self-check” proceed to “Operation
Sheet”.
6. Do the “LAP test” if you are ready.
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.
For example; when you install a DB in your system and access it to practise SQL queries it is
tier-one architecture. But such architecture is rarely used in production
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.
The user interfaces and application programs are run on the client-side.
The server side is responsible to provide the functionalities like: query processing and
transaction management.
To communicate with the DBMS, client-side application establishes a connection with the
server side
2 tier architecture provides added security to the DBMS as it is not exposed to the end user
directly.
This architecture has different usages with different applications. It can be used in web
applications and distributed applications. 3-tier architecture has following layers;
Database server (Data) Tier − at this tier, the database resides along with its query
processing languages. We also have the relations that define the data and their
constraints at this level.
Application (Middle) Tier – also called business logic layer and it processes functional
logic, constraint, and rules before passing data to the user or down to the DBMS. This
DBMS architecture contains an Application layer between the user and the DBMS,
which is responsible for communicating the user's request to the DBMS system and
send the response from the DBMS to the user.
For a user, this application tier presents an abstracted view of the database. End-users
are unaware of any existence of the database beyond the application. At the other end,
the database tier is not aware of any other user beyond the application tier. Hence, the
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. At this layer, multiple views of the
database can be provided by the application. All views are generated by applications
that reside in the application tier. Example your PC, Tablet, Mobile, etc.)
The goal of Three-tier architecture is:
To separate the user applications and physical database
Proposed to support DBMS characteristics
Program-data independence
Support of multiple views of the data
Power failures can lead to hardware failure. The affected hardware components could be
cables, power supplies or storage devices. It can render the data either inaccessible or simply
result in data loss. One would need to isolate the affected area before investigating if the
database was affected by the power failure.
Disk Failure
While power failures can lead to disk failure, they can also fail due to physical damage or a
logical failure. Such 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.
Software Corruption
Companies using traditional in-house IT infrastructures are more at risk of software corruption
than those relying on cloud-based services. While cloud vendors provide flexibility and
scalability of resources, traditional IT environments have fixed sets of hardware resources
which they manually upgrade.
When the number of end users in a company increase, the applications using the same resources
are divided even further among the new users, causing problems such as freezing and crashing
of the operating systems and applications in the middle of using the software. Crashing causes
the end user to lose the unsaved data.
Virus Infection
An enterprise cannot operate safely without the use of a good security solution. 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
Natural disasters such as fire, floods, earthquake, tsunami, etc have the ability to destroy the
entire infrastructure. In such an event, there is absolutely no way to even find, let alone recover,
the data.
Disgruntled Employees
A disgruntled employee could provide essential and confidential information to outsiders,
causing untold damage to an organization. And if the employee has access or gains
unauthorized access to systems or applications, he/she can inject a virus or delete data to halt
the company’s day to day operations.
Hardware Failure
Hardware failure may include 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.
This could be the situation that the system has entered an undesirable state, such as Dead Lock,
which prevents the program form continuing with normal processing.
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:
Ensure that personnel responsible for database backup and recovery are adequately trained
and competent in their roles. Provide ongoing training to keep them updated on the latest
backup and recovery procedures and technologies.
Ergonomics
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.
Security Measures
Implement security measures to protect personnel from potential cybersecurity threats during
backup and recovery operations. Provide guidelines on handling sensitive data securely to
prevent data breaches and unauthorized access.
Equipment Safety
Regularly inspect and maintain all equipment used in database backup and recovery to ensure
it meets safety standards. Provide guidelines for the safe use of backup and recovery tools
and equipment.
Health Monitoring
Implement health monitoring programs to identify and address any health issues among
personnel promptly. Encourage regular health check-ups and screenings to monitor the
overall well-being of employees.
Communication Protocols
Establish effective communication protocols to ensure that team members can communicate
efficiently during backup and recovery operations. Encourage open communication about
any concerns related to health and safety.
Regulatory Compliance
Stay informed about relevant OHS regulations and ensure compliance with local, regional,
and national standards.
This unit is developed to provide you the necessary information regarding the following content
coverage and topics:
Introduction to Backup
Types of backup
Backup and Restoration Methods
Full Offline Backups
Online File Backups
Disk Mirroring and RAID Configurations
Off-site Backup Copies
Onsite Backup
This unit will also assist you to attain the learning outcomes stated in the cover page. Specifically, upon
completion of this learning guide, you will be able to:
Define Backup
Define Types of backup
evaluate different backup and restoration methods
Perform a full offline backup of a database
Adhere to organizational and security standards during the backup process
Execute online file backups following organizational standards
set up and utilize disk mirroring
Establish procedures for creating off-site and On-site backup copies
Restore is the process of retrieving data from a backup. This might mean copying data from
backup media to an existing device or to a new device. It also could mean copying data from
the cloud to a local device or from one cloud to another.
Recovery refers to the process of restoring data and operations (e.g., returning a server to
normal working order following hardware failure).
Restore and recovery times can vary widely depending on the backup format and data recovery
methods you choose. Additionally, restore needs also vary (e.g., restoring a single file vs. an
entire server). Finally, critical data may live on workstations, local servers, and in the cloud.
These are important considerations when selecting a backup and recovery solution. 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
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
2. 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. Backup applications track and
record the date and time that backup operations occur in order to track files modified since
these operations.
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
With that extra storage, organizations should be wary of cost increases and maintenance needs.
In addition, if there's a problem in the source data set, such as a corruption or deletion, the
mirror backup experiences the same. As a result, it's a good idea not to rely on mirror backups
for all your data protection needs, and to have other types of backup for the data. You'll want
to follow the 3-2-1 rule of backup, which includes three copies of data on two different media,
with one copy off site.
Do the right or appropriate backup for your organization. For organizations with small data sets,
running a daily full backup provides a high level of protection without much additional storage space
costs. Larger organizations or those with more data or server volume find that running a weekly full
backup, coupled with either daily incremental backups or differential backups, provides a better option.
Using differentials provides a higher level of data protection with less restore time for most scenarios
and a small increase in storage capacity. For this reason, using a strategy of weekly full backups with
daily differential backups is a good option for many organizations.
An organization must run a full backup at least once. For subsequent backups, it is possible to
run either another full, an incremental or a differential backup. The first partial backup
performed either a differential or incremental, will back up the same data. By the third backup
operation, the data that is backed up with an incremental is limited to the changes since the last
incremental. In comparison, the third backup with a differential will back up all changes since
the first full backup, which was "Backup 1."
From these types of backup, it is possible to develop an approach for comprehensive data
protection. An organization often uses one of the following backup settings:
Full daily
Performing a full backup daily requires the most amount of space, and will also take the most
amount of time. However, more total copies of data are available, and fewer pieces of media
are required to perform a restore operation. As a result, implementing this backup policy has a
higher tolerance to disasters, and provides the least time to restore, since any piece of data
required will be located on at most one backup set.
Running a weekly full backup plus daily differential backup’s delivers results in between the
other alternatives. Namely, more backup media sets are required to restore than with a daily
full policy, although less than with a daily incremental policy. Also, the restore time is less
than using daily incremental backups, and more than daily full backups. In order to restore data
from a particular day, at most two media sets are required, diminishing the time needed to
recover and the potential for problems with an unreadable backup set.
Most of the advanced types of backup such as synthetic full, mirror and continuous data
protection require disk storage as the backup target. A synthetic full simply reconstructs the
full backup image using all required incremental backups or the differential backup on disk.
This synthetic full may then be stored to tape for offsite storage, with the advantage being
reduced restoration time. Finally, continuous data protection enables a greater number of
restoration points than traditional backup options.
It is mostly accomplished before the beginning of the day or at the end of the day. Here a single
backup version is made. Since no new data is added to this in real-time, the backup is
performed swiftly and only once.
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.
However, if the server crashes, the backup will also be gone. The risk that comes with a hot
backup is that the data may be modified during the process, resulting in inconsistent data.
The most important advantage here is the capability to continue business operations while the
backup is in progress. The database is available at all times, and hence the business can
continue as usual.
If you are an organization with business operations working around the clock and cannot afford
any disturbance or downtime, then hot backup is the one for you.
This way, you can safeguard your data and keep your business applications and operations
running. If you are an organization that has fixed working hours, then cold backup is better for
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. It gives the ability to survive one or more drive failure depending upon the RAID level
used.
It consists of an array of disks in which multiple disks are connected to achieve different goals.
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.
Pros of RAID 0:
- In this level, throughput is increased because multiple data requests probably not on the
same disk.
- This level full utilizes the disk space and provides high performance.
- It requires minimum 2 drives.
Cons of RAID 0:
- The main advantage of RAID 1 is fault tolerance. In this level, if one disk fails, then the
other automatically takes over.
- In this level, the array will function even if any one of the drives fails.
Cons of RAID 1:
- In this level, one extra drive is required per drive for mirroring, so the expense is higher.
Pros of RAID 2:
Pros of RAID 3:
In this level, parity can be calculated using an XOR function. If the data bits are 0,0,0,1 then
the parity bits is XOR (0,1,0,0) = 1. If the parity bits are 0,0,1,1 then the parity bit is XOR
(0,0,1,1)= 0. That means, even number of one results in parity 0 and an odd number of one
results in parity 1.
This level allows us to recover lost data.
2.7.6. RAID 5
RAID 5 is a slight modification of the RAID 4 system. The only difference is that in RAID 5,
the parity rotates among the drives. It consists of block-level striping with DISTRIBUTED
parity. Same as RAID 4, this level allows recovery of at most 1 disk failure. If more than one
disk fails, then there is no way for data recovery. This level was introduced to make the random
write performance better.
Pros of RAID 5:
- In this level, disk failure recovery takes longer time as parity has to be calculated from all
available drives.
- This level cannot survive in concurrent drive failure.
2.7.7. RAID 6
This level is an extension of RAID 5. It contains block-level stripping with 2 parity bits. In
RAID 6, you can survive 2 concurrent disk failures. Suppose you are using RAID 5, and RAID
1. When your disks fail, you need to replace the failed disk because if simultaneously another
disk fails then you won't be able to recover any of the data, so in this case RAID 6 plays its
part where you can survive two concurrent disk failures before you run out of options.
- This level performs RAID 0 to strip data and RAID 1 to mirror. In this level, stripping is
performed before mirroring.
- In this level, drives required should be multiple of 2.
Cons of RAID 6:
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.
It is similar to a standard backup process, but uses a facility or storage media that is not
physically located within the organization’s core infrastructure.
Offsite backups are primarily is used in data backup and disaster-recovery measures. The core
objective behind storing and maintaining data at a backup facility is to:
Noisy Neighbours: When choosing offsite storage, it’s important to understand whether you
will be leveraging dedicated offsite storage or if you will be using shared storage.
Organizations supporting databases with a high data change rate will often employ an onsite
backup strategy for quick recovery in the event of a failure.
6. Click on OK button
Purpose: Taking Database Offline using SSMS (SQL Server Management Studio) and T-SQL
5. After Opening SQL Server Management Studio and open a Query Editor pane. Enter
and execute the following code:
USE DB_name;
GO
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.
Task 1: To do the following tasks use database Backup Using SSMS and T-SQL
Task 3: Create a folder named “Data” on the desktop and take the backup of your database in
Data folder using “SSMSbackup” and “TSQLbackup” as a backup name using both SSMS
and T-SQL respectively.
There are many situations in which a transaction may not reach a commit or abort point. Some
of them include;
In any of these situations, data in the database may become inconsistent or lost.
- 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.
Transaction log plays an important role for database recovery and bringing the database in a
consistent state in the event of failure. Transactions represent the basic unit of recovery in a
database system. The recovery manager guarantees the atomicity and durability properties of
transactions in the event of failures. During recovery from failure, the recovery manager
ensures that either all the effects of a given transaction are permanently recorded in the
database or none of them are recorded. A transaction begins with successful execution of a <T,
BEGIN>” (begin transaction) statement.
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.
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.
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.
This transaction log Includes information helpful to the recovery process such as: A
transaction identifier, the date and time, the user running the transaction, before
images and after images.
Before Image: A copy of the table record (or data item) before it was changed by
the transaction.
After Image: A copy of the table record (or data item) after it was changed by
the transaction.
The Automated Recovery process uses both rollback and roll forward to restore the
database.
STEP1: UNDO-list = list of transactions given in the checkpoint record = {T2, T3}
REDO-list = { }
STEP2: Search forward through the log, starting from the checkpoint, to the end of log:
• If a 'BEGIN TRANSACTION' is found => add to UNDO-list {T2, T3, T4, T5}
UNDO-list = {T3, T5} (System works backward through the log, undoing the UNDO-List.)
REDO-list = {T2, T4} (System then works forward through the log, redoing the REDO-List)
The ability to perform this kind of recovery depends on a recovery model set for the database.
The database must be in either the Full or Bulk-Logged recovery model. In case the Simple
recovery mode was used, this recovery method is not possible.
In case of using the Bulk-Logged recovery model some errors may occur and recovery to a
point in time might fail. An error will be thrown in case when any bulk-logged operations were
performed. As such operations are minimally logged; there is not sufficient data in a particular
transaction log.
When you issue a RESTORE DATABASE or RESTORE LOG command the WITH
RECOVERY option is used by default.
If you restore a "Full" backup the default setting it to RESTORE WITH RECOVERY, so after
the database has been restored it can then be used by your end users.
If your database is still in the restoring state and you want to recover it without restoring
additional backups you can issue a RESTORE DATABASE. WITH RECOVERY to bring the
database online for users to use.
The RESTORE ... WITH NORECOVERY option puts the database into a "restoring" state, so
additional backups can be restored. When the database is in a "restoring" state no users can
access the database or the database contents.
When you issue a RESTORE DATABASE or RESTORE LOG command; the WITH
NORECOVERY option allows you to restore additional backup files before recovering the
database. This therefore allows you to get the database as current as possible before letting
your end users access the data.
This option is not on by default, so if you need to recover a database by restoring multiple
backup files and forget to use this option you have to start the backup process all over again.
The most common example of this would be to restore a "Full" backup and one or more
"Transaction Log" backups.
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
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
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
Steps
7. Click OK button
URL
https://www.guru99.com/dbms-architecture.html
https://learn.org/articles/What_is_Database_Architecture.html
https://www.javatpoint.com/dbms-architecture
https://searchdatabackup.techtarget.com/feature/Full-incremental-or-differential-How-
to-choose-the-correct-backup-type
https://www.datto.com/blog/data-backup-and-recovery-methods-the-basics-you-need-
to-know
https://www.backup4all.com/mirror-backup-kb.html
https://www.mssqltips.com/sqlservertutorial/112/recovering-a-sql-server-database-that-is-in-the-
restoring-state/
https://www.tutorialspoint.com/dbms/dbms_data_recovery.htm
1 Frew Atkilt M-Tech Network & Information Bishoftu Polytechnic 0911787374 frew.frikii@gmail.com
Security College
5 Tewodros Girma MSc Information system Sheno Polytechnic 0912068479 girmatewodiros @gmail.com
College