Tuesday, March 10, 2015

Recovery Models in SQL Server


Recovery models
===============
Simple Recovery Model
----------------------
When you choose simple recovery model, SQL Server maintains only a minimal amount of information in the transaction log. SQL Server truncates the transaction log each time the database reaches a transaction checkpoint, leaving no log entries for disaster recovery purposes.

In databases using the simple recovery model, you may restore full or differential backups only. It is not possible to restore such a database to a given point in time, you may only restore it to the exact time when a full or differential backup occurred. Therefore, you will automatically lose any data modifications made between the time of the most recent full/differential backup and the time of the failure.

Simple Recovery is not an appropriate choice for production systems where loss of recent changes is unacceptable. When using Simple Recovery, the backup interval should be long enough to keep the backup overhead from affecting production work, yet short enough to prevent the loss of significant amounts of data.

Advantage: permits high-performance bulk copy operations. Reclaims log space to keep space requirements small.

Disadvantage: changes since the most recent database or differential backup must be redone.

Full Recovery Model
------------------------
With full recovery model, SQL Server preserves the transaction log until you back it up. This allows you to design a disaster recovery plan that includes a combination of full and differential database backups in conjunction with transaction log backups.

You have the most flexibility restoring databases using the full recovery model when a database failure happens. In addition to preserving data modifications stored in the transaction log, the full recovery model allows you to restore a database to a specific point in time.

Advantage: no work is lost due to a lost or damaged data file. It can recover to an arbitrary point in time.

Disadvantage: if the log is damaged, changes since the most recent log backup must be redone.

Bulk-logged Recovery Model
-----------------------------------------
The bulk-logged recovery model is a special-purpose model that works in a similar manner to the full recovery model. The only difference is in the way it handles bulk data modification operations. The bulk-logged model records these operations in the transaction log using a technical known as minimal logging. This saves significantly on processing time, but prevents you from using the point-in-time restore option.

Advantage: permits high-performance bulk copy operations, minimal log space is used by bulk operations.

Disadvantage: if the log is damaged, or bulk operations occurred since the most recent log backup, changes since that last backup must be redone.

Example:-

ALTER DATABASE Pubs SET RECOVERY FULL
GO

1 comment:

COMMON SQL SERVER BACKUP FAILURE ERRORS AND ISSUES

  One of the most common task for a DBA’s are to perform installation of new SQL Server versions and installing patches. Most often or not e...