Full recovery Model
The
"Full" recovery model tells SQL Server to keep all transaction data
in the transaction log until either a transaction log backup occurs or the
transaction log is truncated. The way this works is that all transactions that
are issued against SQL Server first get entered into the transaction log and
then the data is written to the appropriate data file. This allows SQL
Server to rollback each step of the process in case there was an error or the
transaction was cancelled for some reason. So when the database is set to
the "Full" recovery model since all transactions have been saved you
have the ability to do point in time recovery which means you can recover to a
point right before a transaction occurred like an accidental deletion of all
data from a table.
The full
recovery model is the most complete recovery model and allows you to recover
all of your data to any point in time as long as all backup files are useable.
With this model all operations are fully logged which means that you can
recover your database to any point. In addition, if the database is set to the
full recovery model you need to also issue transaction log backups otherwise
your database transaction log will continue to grow forever.
Here are some reasons why you may choose this
recovery model:
- Data
is critical and data can not be lost.
- You
always need the ability to do a point-in-time recovery.
- You
are using database mirroring
Type of backups you can run when the data is in
the "Full" recovery model:
- Complete
backups
- Differential
backups
- File
and/or Filegroup backups
- Partial
backups
- Copy-Only
backups
- Transaction
log backups
ALTER
DATABASE AdventureWorks SET RECOVERY FULL
GO
GO
Simple recovery model
The
"Simple" recovery model does what it implies, it gives you a simple
backup that can be used to replace your entire database in the event of a
failure or if you have the need to restore your database to another
server. With this recovery model you have the ability to do complete
backups (an entire copy) or differential backups (any changes since the last
complete backup). With this recovery model you are exposed to any
failures since the last backup completed.
The
"Simple" recovery model is the most basic recovery model for SQL
Server. Every transaction is still written to the transaction log, but
once the transaction is complete and the data has been written to the data file
the space that was used in the transaction log file is now re-usable by new
transactions. Since this space is reused there is not the ability to do a
point in time recovery, therefore the most recent restore point will either be
the complete backup or the latest differential backup that was completed.
Also, since the space in the transaction log can be reused, the transaction log
will not grow forever as was mentioned in the "Full" recovery model.
Here are some reasons why you may choose this
recovery model:
- Your
data is not critical and can easily be recreated
- The
database is only used for test or development
- Data
is static and does not change
- Losing
any or all transactions since the last backup is not a problem
- Data
is derived and can easily be recreated
Type of backups you can run when the data is in
the "Simple" recovery model:
- Complete
backups
- Differential
backups
- File
and/or Filegroup backups
- Partial
backups
- Copy-Only
backups
ALTER
DATABASE AdventureWorks SET RECOVERY SIMPLE
Bulk-logged recovery model
The
"Bulk-logged" recovery model sort of does what it implies. With
this model there are certain bulk operations such as BULK INSERT, CREATE INDEX,
SELECT INTO, etc... that are not fully logged in the transaction log. The
advantage of using the "Bulk-logged" recovery model is that your
transaction logs will not get that large if you are doing bulk operations and
it still allows you to do point in time recovery as long as your last transaction
log backup does not include a bulk operation as mentioned above. If no
bulk operations are run, this recovery model works the same as the Full
recovery model. One thing to note is that if you use this recovery model
you also need to issue transaction log backups otherwise your database
transaction log will continue to grow.
Here are some reasons why you may choose this
recovery model:
- Data
is critical, but you do not want to log large bulk operations
- Bulk
operations are done at different times versus normal processing.
- You
still want to be able to recover to a point in time
Type of backups you can run when the data is in
the "Bulk-logged" recovery model:
- Complete
backups
- Differential
backups
- File
and/or Filegroup backups
- Partial
backups
- Copy-Only
backups
- Transaction
log backups
ALTER
DATABASE AdventureWorks SET RECOVERY BULK_LOGGED
No comments:
Post a Comment