Database Recovery Models

Database recovery is a very important thing, especially to DBA’s, and the occasional developer who screws something up.  Please note, I am a developer and I would NEVER mess ANYTHING up in a database.  I treat all databases equally and with respect.  Anyway, we are getting off track.  There are three recovery models: Simple, Full and Bulk-Logged.
Simple:  This method does not do log backups.  This causes an issue on systems where if a failure occurs then recent data needs to be recovered.  If you are only loading something like a data warehouse once a day then this may be a good option as you don’t have new transactions writing to the database all day.  You only care about the data at the single point in time of loading.  Any changes in the database since the last backup will be lost.
Full:  This method allows you performs log backups.  This method will allow a point in time restore of your environment.  All transactions in the logs are kept until a transaction log backup is performed.  Individual data pages can also be restored under this method. Also note that the only thing that will clear the transaction logs are transaction log backups. Here is a link to Paul Randal’s blog on backup myths.
Bulk-Logged:  Logs are backed up here as well.  Here if the log gets damaged or a bulk-logged operation happens between the point of last backup and disaster all those operations must be redone.  If there are no bulk-logged operations since the last backup then no data needs to be reloaded.  Note that point in time recovery is NOT supported with this method.
Knowing the difference between these options is critical.  There comes a time when you will need to know what model your databases are using.  Luckily there are several ways to do this, the one in particular that I will show is how to get all databases recovery model they are currently set up with.
SELECT
recovery_model_desc AS RecoveryModel
,name AS DatabaseName
FROM sys.databases
ORDER BY DatabaseName
You can also programmatically change the model of a database by using ALTER DATABASE as shown below.
ALTER DATABASE AdventureWorks
SET RECOVERY SIMPLE
The syntax for the three RECOVERY model options: SIMPLE, FULL OR BULK_LOGGED

About the author

Bradley Schacht

Bradley Schacht is a Senior Program Manager on the Microsoft Azure Synapse Analytics team based in Jacksonville, FL. He has worked with Microsoft SQL Server and Azure data services since 2009 as a consultant, trainer, and architect. He has co-authored 4 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. Bradley enjoys solving interesting problems and teaching others to use new technology. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Bradley Schacht

Bradley Schacht is a Senior Program Manager on the Microsoft Azure Synapse Analytics team based in Jacksonville, FL. He has worked with Microsoft SQL Server and Azure data services since 2009 as a consultant, trainer, and architect. He has co-authored 4 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. Bradley enjoys solving interesting problems and teaching others to use new technology. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

Follow Me