Complet DB Backup and Recovery
Complet DB Backup and Recovery
MODULE DESCRIPTION
This module covers the knowledge, skills and required to back-up and recover a database
LEARNING OUTCOMES:
Because transaction log backups are backups of log entries, it is even possible to perform a
backup from a transaction log if the data files are destroyed. With this backup, it is possible to
recover the database up to the last transaction that took place before the failure occurred.
2.3. Recover immediate update
Immediate update, or UNDO/REDO, is another algorithm to support ABORT and machine failure
scenarios.
Database may be updated by some operations of a transaction before the transaction reaches its
commit point.
- Commit means Make changes done in transaction permanently. A transaction is a set of SQL
statements.
If a transaction fail after recording some change to the database, but before commit point, the effect of
its operations on the database must be undone (transaction must be rollback).
- Undo Operations need to be performed for all unfinished transactions.
2.4. Shadow paging
Shadow paging is a technique for providing atomicity and durability in database system. A page, in
this context, refers to a unit of physical storage.
Shadow paging is a copy-on-write technique for avoiding in-place updates of pages.
In shadow paging, when a write_item operation is performed:
A new copy of the modified DB page is created and the old copy is not overwritten.
The new page is written elsewhere on some unused disk block.
The current directory entry is modified to point to the new disk block.
The shadow directory is not modified.
Shadow copies; the current copies of data items
Repeating history during redo: When the system restarts after a crash, ARIES retraces all the
actions of database system prior to the crash to bring the database to the state which existed at
the time of the crash.
It then undoes the actions of all the transactions that were not committed at the time of the
crash.
Logging changes during undo: A separate log is maintained while undoing a transaction to
make sure that the undo operation once completed is not repeated in case the failure occurs
during the recovery itself, which causes restart of the recovery process.
The ARIES recovery procedure consists of three main steps:
- Analysis: It identifies the dirty (updated) pages in the buffer and the set of transactions active at the
time of crash.
- REDO phase: It actually reapplies updates from the log to the database. Generally the REDO
operation is applied
to only committed transactions.
- UNDO phase: The log is scanned backwards and the operations of transactions that were active at the
time of the crash are undone in reverse order. The information needed for ARIES to accomplish its
recovery procedure includes the log, the transaction table, and the dirty page table.
2.6. Recovery in multi DB system
A multi-database consists of a collection of autonomous local databases.
To maintain the atomicity of a multidatabase transaction, it is necessary to have a two-level recovery
mechanism.
A global recovery manager or coordinator is needed to maintain information needed for recovery, in
addition to the local recovery managers and the information they maintain (log, tables).
In MDBSs, recovering multi-database consistency has a twofold meaning. First, for global transaction
aborts, recovering multi-database consistency means to undo the effects of locally committed
subsequences belonging to the aborted global transactions from a semantic point of view.
In addition, the effects of transactions which have accessed objects updated by aborted global
transactions should be preserved (recall that, after the last operation of a subsequence, all locks held by
the subsequence are released).
For the other types of failures, recovering multi-database consistency means to restore the most recent
global transaction-consistent state.
2.7. DB Backup from Catastrophic failures
Failure can happen for any number of reasons.
User error is the number one reason for data damage, loss, or corruption.
This type of failures include: application modifying or destroying the data on its own or through a
user choice.
Media failure can happen when the media of the data files or transaction logs failed.
Disastrous or catastrophic event. This can be in the form of fire, flood, or any naturally occurring
storm.
It can also happen through electrical outage, a virus, or the deliberate hacking of your data. Any of
these can corrupt or cause the loss of your data.
The recovery manager of a DBMS must be equipped to handle more catastrophic failures such as disk
crashes.
The main technique used to handle such crashes is that of database backup. The whole database and
the log are periodically copied onto a cheap storage medium such as magnetic tapes. In case of a
catastrophic system failure, the latest backup copy can be reloaded from the tape to the disk, and the
system can be restarted.
To avoid losing all the effects of transactions that have been executed since the last backup, it is
customary to back up the system log at more frequent intervals than full database backup by
periodically copying it to magnetic tape. The system log is usually substantially smaller than the
database itself and hence can be backed up more frequently.
Hence, to recover from disk failure, the database is first recreated on disk from its latest backup copy
on tape.
Once you click on the “Backup” the following Backup Database window will appear.
Step 5: Now, by clicking on the “Add” button, the following window will appear to select the path
and file name for the database backup file [as shown in the image below]:
Step 6: Select the destination folder for the backup file and enter the “File name” with .bak extension
[as shown in the image below]:
Make sure you place your MS SQL database .bak file under the MSSQL backup folder.
Step 7: Hit the OK button to finish the backup of your MS SQL Server 2008 Database. Upon the
successful completion of database backup, the following confirmation window will appear with a
message “The backup of database “yourdatabasename” completed successfully. [as shown in the
image below]:
Following the above shown steps, you will be able to create a successful backup of your MS SQL
Server 2008 Database into the desired folder.
Step 3: The following “Restore Database“windows will appear. Select “From device” mentioned
under the “Source for restore” and click the button in front of that to specify the file location [as shown
in the image below]:
Step 4: Select the option “Backup media as File” and click on the Add button to add the backup file
location [as shown in the image below]:
Step 5: Select the backup file you wish to restore and Hit the OK button [as shown in the image
below]:
You will get the confirmation windows with a message “The restoration of database
“yourdatabasename” completed successfully.” Now you know the procedure of backing up and
restoring MS SQL Server 2008 Database.
Step 6: Once this has completed, a pop-up will say the database has been restored successfully. Click
OK.
You can create a back up and restore using SQL transaction code: use master
BACKUP DATABASE Employee TO DISK = 'D:\Employee.bak'
restore DATABASE Employee from disk= 'D:\Employee.bak'