Data Backup and Recovery in DBMS: Protecting Against Data Loss

Learn about the importance of data backup in DBMS and the challenges posed by volatile storage loss. Explore effective techniques to protect your database against data loss and ensure efficient recovery in case of failures.



DBMS - Data Backup

Loss of Volatile Storage

A volatile storage like RAM stores all the active logs, disk buffers, and related data. It also keeps track of all transactions currently being executed. If such a volatile storage crashes abruptly, it will result in the loss of all logs and active copies of the database. This situation makes recovery almost impossible, as everything required to restore the data is lost.

Techniques for Handling Loss of Volatile Storage

To mitigate the impact of volatile storage loss, the following techniques can be adopted:

  • Implement checkpoints at multiple stages to save the contents of the database periodically.
  • Periodically dump the state of the active database in volatile memory onto stable storage, which may also contain logs and active transactions, as well as buffer blocks.
  • Mark a <dump> on a log file whenever the database contents are dumped from non-volatile memory to a stable one.

Recovery

When the system recovers from a failure, it can restore the latest dump. Recovery can be achieved through the following methods:

  • Maintaining a redo-list and an undo-list as checkpoints.
  • Consulting undo-redo lists to restore the state of all transactions up to the last checkpoint.

Database Backup & Recovery from Catastrophic Failure

A catastrophic failure occurs when a stable, secondary storage device becomes corrupt, leading to the loss of all valuable data stored within. To recover data from such failures, we have two different strategies:

Remote Backup

Remote backup involves storing a backup copy of the database at a remote location from which it can be restored in case of a catastrophe.

Alternatively, database backups can be taken on magnetic tapes and stored in a safe location. This backup can later be transferred to a newly installed database to restore it to the point of backup.

Backup Strategy for Large Databases

Large databases are often too bulky to be backed up frequently. In such cases, techniques that allow for restoring a database by examining its logs are used. This approach requires taking backups of all logs at regular intervals. For instance, the database can be backed up once a week, while logs, being smaller, can be backed up every day or even more frequently.

Remote Backup

Remote backup provides security in case the primary location where the database is located is destroyed. It can be classified as offline or online:

  • Offline backups are maintained manually.

Remote Data Backup

Online backup systems are more real-time and act as lifesavers for database administrators and investors. An online backup system ensures that every piece of real-time data is backed up simultaneously at two distant locations. One is directly connected to the system, while the other serves as a remote backup.

When the primary database storage fails, the backup system detects the failure and switches the user system to the remote storage. In some cases, this transition is so swift that users may not even notice the failure.