SlideShare a Scribd company logo
1 of 5
Download to read offline
27/08/2012                       SQL server Recovery Models and Backup types « Sql server Blog Forum



                                                                                                Sql server Blog Forum




                Backup/Restore
                SQL server Recovery Models and Backup types

      SQL server Recovery Models and Backup types
        by Muthukkumaran kaliyamoorthy Published on: June 7, 2011
        C omments: 21 C omments
        Tags: Recovery models importance, SQL RPO RTO, SQL server Backup types, SQL server Recovery Models
        C ategories:Backup/Restore, Basics for freshers, Internals

      In this post I am going to explain the importance of recovery models and backup types.
      Why I am writing this post ?
      Because, when I was teaching about the topic to my PHP friend .He got doubts on bulk logged recovery model and
      differential backups. I have given some examples and cleared his doubts. I am going to share this with you guys
      too.
      I hope this will help for Freshers and DBA managers.
      Recovery models and backup types are important to plan the recovery point objective (RPO) and recovery time
      objective (RTO). We can’t differentiate the recovery models and backup types. Simply it’s a mixture.
      Let’s see the discussion.
      Manager:
      We need minimum data loss and downtime.
      DBA:
      The existing system has low disk space and the transaction log backups are failing often. We need more disk
      space to do this, Sir!
      Manager:
      I asked about this to management they will give soon, until you will do something with your DBA knowledge.
      DBA:
      C hanging the recovery models full to simple and back to full and shrinking the log file daily. The DBA send an
      email to his manager. The shrinking is not best practices, Sir!
      Manager:
      ???


      Let’s come to the point.
      Recovery Models
      SQL server has three types of recovery models.


      1. Full
      2. Bulk Logged
      3. Simple
      Full

                In full recovery model all the database operations are fully logged. This means all the modifications have
                written fully to the log file.

                The full recovery model is always the best one for production servers.

                In the full recovery model we can take all kinds of backups like full, differential, transaction Log and point
                in time recovery (PTR) too.

      Bulk Logged

                The name itself you can understand the answer. Bulk operations minimally logged in this mode. This means
                it has written only minimal roll backing information to the log file not whole (i.e. not fully logged). The BCM
                page contains all the required information. See an example you can understand.

                Bulk logged recovery model is the best model for server performance. Because all the bulk changes have

www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/                                                   1/5
27/08/2012                       SQL server Recovery Models and Backup types « Sql server Blog Forum

                been written minimally (Not fully) to the transaction log file.

                In bulk logged recovery model we can take all kinds of backups like full, differential and transaction Log
                but, the drawback is the point in time recovery (PTR)is not possible, when there is a bulk operations have
                done with the transaction log file.

      Keep in mind, in full and bulk logged recovery model the log files grow bigger until the BAC KUP LOG has done.
      For more clarity. See an example:
      Just assume 5,000 bulk operations have written in 8000 pages.
      In full recovery model each 5,000 bulk operations have written in 8000 pages, because all the changes have
      written fully in the full recovery model.
      But when we used bulk logged recovery model, it has written 1000 pages only ,Because SQL server has written
      the bulk changes to an extent wise not the page wise i.e. minimally logged operation (8 pages = 1 extent). It will
      help to improve the overall server performance.
      Now you know, Writing 8000 pages are good or 1000 pages.
      Note: This bulk logged model is good only for the bulk operations.


      Simple

                The name itself you can understand the answer. Simple recovery model is just simple this means SQL
                server will run the checkpoint every minute and truncate the transaction log file often. Mostly the log file
                will not grow larger.

                Most of the time the simple recovery model is a good choice for non production servers. Because the log
                file will not grow larger. Also we would not take log backups. (If you’re planning to take the log backup
                then don’t put in simple)

                In the simple recovery model the transaction log backup is not possible. We can take full and differential
                backups only.

                Now you could know answer for the following questions.
                What is the use of Full, Bulk logged and Simple recovery model.
                Which one is best?


      Backup Types
      SQL server has number of backup types. Here I am going to explain the main three types.
      1. Full
      2. Differential
      3. Transaction log
      I recommend to read Paul S Randals’s backup survey post.
      http://www.sqlskills.com/BLOGS/PAUL/post/Importance-of-having-the-right-backups.aspx


      Full backup

                A full backup backs up the full/whole database. That backs up all the committed data.

                The full database backup has been done in all the recovery models.

      Differential backup

                A differential backup only backs up the changed data/extents that were modified after the full database
                backup has done. The DCM has tracked all the changed extents.

                The differential backup has been done in all the recovery models.

      For more clarity. See an example:
      Assume we are scheduled every Sunday full backup @12 am and daily differential backup 10 PM.
      Note: The data change daily 500 MB.
      Question:
      How much data got back up on Thursday?
      The student answers 500 MB.
      As I already told, differential database backup “backs up all the data that has changed since the last full database
      backup”.
      The answer is,
      Monday 500MB + Tuesday 500 MB + Wednesday 500MB + Thursday 500MB= 2000MB

www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/                                                2/5
27/08/2012                       SQL server Recovery Models and Backup types « Sql server Blog Forum

      Edit: I added these lines after I had replied the forum question SSC .
      So the differential backup on Thursday has all the data. That is (Monday+Tuesday+Wednesday+Thursday). It
      helps to bring the database online as quickly as possible.
      Transaction log backup

               A transaction log backup backs up the transaction log file. That is all the modifications/changes.

               The transaction log backup only possible in full and bulk logged recovery model.

               The transaction log backup is important to minimize data loss and log file size too.

      It’s very important to keep the transaction log backup as much as safe, because the restoration needs the
      sequence of the transaction log backup if, you deleted/missing any one of the backups then you can’t recover the
      whole data.
      I have suggested running the log backups often. It will reduce the log file size and helps to minimize your data
      loss.
      Question:
      How to restore the database after a disaster? (OR) What is the sequence to restore the database?
      Answer:
      Restore a full backup and followed by recent differential backup and all the log backup one by one in a sequence.
      For more clarity. See an example:
      Assume we are scheduled every Sunday full backup @12 am and daily differential backup 10 PM and an hourly log
      backup.
      The database crashed on Wednesday at 1:30 PM. Then the restoration will be on Sunday full backup+ Wednesday
      differential backup (Most recent) + log backup @11+@12+@1.
      Believe me guys, Test your backups often and keep at least two copy of the full backups safely, Because the full
      backup is important to restore the all other backups. This means without a full backup you can’t restore the
      differential and log backups.




                                          Muthukkumaran kaliyamoorthy
                                          I’m currently working as a SQL server DBA in one of the top MNC . I’m passionate
                                          about SQL Server And I’m specialized in Administration and Performance tuning.
                                          I’m an active member of SQL server C entral and MSDN forum. I also write articles
                                          in SQL server C entral. For more Click here
                                          More Posts - Website




      Share this


                                                                                                       21 C omments - Leave a comment

                ram                                                                                          June 7, 2011 at 11:22 am
                dude,superb , very useful to understand the basic recovery model and backup types and the way which
                you explained s nice

                Muthukkumaran                                                                                June 7, 2011 at 12:01 pm
                I wrote this post after we had a class discussion. Thanks to you dude.

                Anonymous                                                                                     June 7, 2011 at 3:43 pm
                Hi Muthu
                1. As you said, In-case of any disaster on Wednesday @ 1:30 pm.
                2. We have to perform the "Tail-Log" backup first. Then only we will have last 30 minutes transaction after
                the actual transaction-log hourly backup. correct ?
                3. Then, we have to proceed with further Restore either (Norecovery or Standby state)

                Muthukkumaran                                                                                 June 8, 2011 at 6:01 am
                @Anonymous user
                Yep, You are right.we can take the tail log backup if, there is no damage in transaction log file.I didn't
                focus the restore part fully. It's just an example to understand the restoration sequence to all the
                newbies.

www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/                                                         3/5
27/08/2012                       SQL server Recovery Models and Backup types « Sql server Blog Forum

                Thanks to reading my posts.
                i don't know most of my comments are from Anonymous user. Nobody is writing his name.

                Anonymous                                                                                 June 9, 2011 at 11:40 am
                Spot-on post.I agree with the first person comment the way you explained really superb and it's written
                using very simple/understandable english.
                keep up the good work.
                Great examples.
                BY
                Yardy

                Muthukkumaran                                                                              June 9, 2011 at 5:31 pm
                @yardy glad you liked it.thanks
                To be frank i don’t know complex words.lol

                vinoth                                                                                    June 11, 2011 at 6:21 am
                Hi muthu,
                Great post.
                I liked this.
                Monday 500MB + Tuesday 500 MB + Wednesday 500MB + Thursday 500MB= 2000MB

                Muthukkumaran                                                                             June 21, 2011 at 9:13 am
                So the differential backup on Thursday has all the data. That is
                (Monday+Tuesday+Wednesday+Thursday). It helps to bring the database online as quickly as possible.
                I have added these lines after i replied the forum question
                http://www.sqlservercentral.com/Forums/Topic1128012-391-2.aspx?Update=1

                Anonymous                                                                                  July 9, 2011 at 9:36 am
                H Muthu,
                I am new to SQL DBA group.
                I have doubt here about DR, as you said the DB crashed on Wed at 1:30 PM
                Below is the sequential backup i have backup:
                Sun – Full backup @ 12:00 AM (Mid-Night)
                Mon – Differential Backup @ 10: PM (Night)
                Tue – Diff @ 10:PM (Night)
                Wed – DB crashed @ 1:30 PM (Afternoon)
                Than my question here is how come we follow restore with – Sun full backup + WED Diff because if DB
                crashed at 1:30 PM (Noon) on wed thn we don't have WED's diff backup (night)as DB crashed in Noon.
                So do we need to add tuesday's Differentail Backup.
                Please clarify my doubt.
                thanks-
                Pooja

                Muthukkumaran                                                                             July 9, 2011 at 10:55 am
                Pooja,
                Yep you are right. If you have log backup you can restore that too.
                If you want more answer I suggest you to ask questions to SQlservercentral and MSDN forum.

                this post is quoted by SQL server Disaster Recovery plan « SqlserverBlogForum 9, 2011 at 2:19 pm
                                                                                       October
                [...] its simple(less expensive) and good option for disaster recovery but it’s depends upon your backup
                strategy and recovery model. The backup restore will work for all the above three DR methods. The
                DBA job is keep the data [...]

                this post is quoted by Difference between truncating and shrinking the transaction2011 file « pm
                                                                                         October 9, log at 3:34
                SqlserverBlogForum
                [...] It depends upon the recovery model. [...]

                Myrman                                                                                 October 31, 2011 at 1:04 am
                Thank you for making your work very easy to comprehend. The topic is somewhat baffling as it is but you
                make it look easy. This is just what people need to read.



www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/                                                      4/5
27/08/2012                       SQL server Recovery Models and Backup types « Sql server Blog Forum

                         Muthukkumaran kaliyamoorthy                                                                October 31, 2011 at 7:23 pm
                         Glad you liked it.Thanks.

                Deandrea Nodine                                                                                  November 3, 2011 at 10:29 pm
                Useful page and incredibly informative. Thanks for taking the time to write it and post it!

                         Muthukkumaran kaliyamoorthy                                                             November 4, 2011 at 11:35 am
                         Thanks Deandrea Nodine.

                Mellie Partible                                                                                   November 6, 2011 at 8:51 am
                You, my friend, ROC K! I found just the info I already searched everywhere and just could not locate it.
                What a perfect website. I have bookmarked your website:
                http://www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ and will
                check back often. Thanks for the awesome information!

                         Muthukkumaran kaliyamoorthy                                                             November 6, 2011 at 11:01 am
                         I’m glad you liked it.

                Dee Lazich                                                                                       February 11, 2012 at 12:58 am
                I don’t even understand how I finished up right here, however I assumed this publish was once great. I
                do not recognize who you might be however certainly you’re going to a well-known blogger should you
                are not already          C heers!

                         Muthukkumaran kaliyamoorthy                                                             February 11, 2012 at 11:26 am
                         I’m glad it helps you.
                         Thanks Dee.

                this post is quoted by Server Data Recovery | Data Recovery                                            May 18, 2012 at 10:48 am
                [...] Server Data Store for Distribution Perform these steps for both servers: 1. … Fetch C ontent Two-
                phase C ommit Protocol – Wikipedia, The Free EncyclopediaTo accommodate recovery from failure (a…
                sform:capitalize;">Two-phase C ommit Protocol – Wikipedia, The Free EncyclopediaTo accommodate [...]

                                                                         © 2 0 1 2 Sql server Blog Forum A ll rights res erved - P owered by WordP res s




www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/                                                                            5/5

More Related Content

Viewers also liked

Common SQL Server Backup Problems
Common SQL Server Backup ProblemsCommon SQL Server Backup Problems
Common SQL Server Backup ProblemsGrant Fritchey
 
SQL Server Backup and Recovery Challenges
SQL Server Backup and Recovery ChallengesSQL Server Backup and Recovery Challenges
SQL Server Backup and Recovery ChallengesSQLDBApros
 
Database backup and recovery basics
Database backup and recovery basicsDatabase backup and recovery basics
Database backup and recovery basicsShahed Mohamed
 
MS SQL Server 2014 - In-Memory OLTP
MS SQL Server 2014 - In-Memory OLTPMS SQL Server 2014 - In-Memory OLTP
MS SQL Server 2014 - In-Memory OLTPJoseph Lopez
 
websphere MQ training Online
websphere MQ training Onlinewebsphere MQ training Online
websphere MQ training OnlineDivya Angel
 
MICROSOFT SQL SERVER 2012
MICROSOFT SQL SERVER 2012MICROSOFT SQL SERVER 2012
MICROSOFT SQL SERVER 2012LaGeJa
 
IBM MQ Online Tutorials
IBM MQ Online TutorialsIBM MQ Online Tutorials
IBM MQ Online TutorialsBigClasses.com
 
IBM Websphere MQ Basic
IBM Websphere MQ BasicIBM Websphere MQ Basic
IBM Websphere MQ BasicPRASAD BHATKAR
 
Sql 2012 always on
Sql 2012 always onSql 2012 always on
Sql 2012 always ondilip nayak
 
Websphere MQ admin guide
Websphere MQ admin guideWebsphere MQ admin guide
Websphere MQ admin guideRam Babu
 
2.6 backup and recovery
2.6 backup and recovery2.6 backup and recovery
2.6 backup and recoverymrmwood
 
Always on in SQL Server 2012
Always on in SQL Server 2012Always on in SQL Server 2012
Always on in SQL Server 2012Fadi Abdulwahab
 
IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction ejlp12
 

Viewers also liked (15)

Optimizing your backup
Optimizing your backupOptimizing your backup
Optimizing your backup
 
Common SQL Server Backup Problems
Common SQL Server Backup ProblemsCommon SQL Server Backup Problems
Common SQL Server Backup Problems
 
SQL Server Backup and Recovery Challenges
SQL Server Backup and Recovery ChallengesSQL Server Backup and Recovery Challenges
SQL Server Backup and Recovery Challenges
 
Database backup and recovery basics
Database backup and recovery basicsDatabase backup and recovery basics
Database backup and recovery basics
 
MS SQL Server 2014 - In-Memory OLTP
MS SQL Server 2014 - In-Memory OLTPMS SQL Server 2014 - In-Memory OLTP
MS SQL Server 2014 - In-Memory OLTP
 
websphere MQ training Online
websphere MQ training Onlinewebsphere MQ training Online
websphere MQ training Online
 
MICROSOFT SQL SERVER 2012
MICROSOFT SQL SERVER 2012MICROSOFT SQL SERVER 2012
MICROSOFT SQL SERVER 2012
 
IBM MQ Online Tutorials
IBM MQ Online TutorialsIBM MQ Online Tutorials
IBM MQ Online Tutorials
 
IBM Websphere MQ Basic
IBM Websphere MQ BasicIBM Websphere MQ Basic
IBM Websphere MQ Basic
 
Sql 2012 always on
Sql 2012 always onSql 2012 always on
Sql 2012 always on
 
Websphere MQ admin guide
Websphere MQ admin guideWebsphere MQ admin guide
Websphere MQ admin guide
 
2.6 backup and recovery
2.6 backup and recovery2.6 backup and recovery
2.6 backup and recovery
 
Always on in SQL Server 2012
Always on in SQL Server 2012Always on in SQL Server 2012
Always on in SQL Server 2012
 
IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction IBM WebSphere MQ Introduction
IBM WebSphere MQ Introduction
 
IBM MQ V9 Overview
IBM MQ V9 OverviewIBM MQ V9 Overview
IBM MQ V9 Overview
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Sql server recovery models and backup types « sql server blog forum

  • 1. 27/08/2012 SQL server Recovery Models and Backup types « Sql server Blog Forum Sql server Blog Forum Backup/Restore SQL server Recovery Models and Backup types SQL server Recovery Models and Backup types by Muthukkumaran kaliyamoorthy Published on: June 7, 2011 C omments: 21 C omments Tags: Recovery models importance, SQL RPO RTO, SQL server Backup types, SQL server Recovery Models C ategories:Backup/Restore, Basics for freshers, Internals In this post I am going to explain the importance of recovery models and backup types. Why I am writing this post ? Because, when I was teaching about the topic to my PHP friend .He got doubts on bulk logged recovery model and differential backups. I have given some examples and cleared his doubts. I am going to share this with you guys too. I hope this will help for Freshers and DBA managers. Recovery models and backup types are important to plan the recovery point objective (RPO) and recovery time objective (RTO). We can’t differentiate the recovery models and backup types. Simply it’s a mixture. Let’s see the discussion. Manager: We need minimum data loss and downtime. DBA: The existing system has low disk space and the transaction log backups are failing often. We need more disk space to do this, Sir! Manager: I asked about this to management they will give soon, until you will do something with your DBA knowledge. DBA: C hanging the recovery models full to simple and back to full and shrinking the log file daily. The DBA send an email to his manager. The shrinking is not best practices, Sir! Manager: ??? Let’s come to the point. Recovery Models SQL server has three types of recovery models. 1. Full 2. Bulk Logged 3. Simple Full In full recovery model all the database operations are fully logged. This means all the modifications have written fully to the log file. The full recovery model is always the best one for production servers. In the full recovery model we can take all kinds of backups like full, differential, transaction Log and point in time recovery (PTR) too. Bulk Logged The name itself you can understand the answer. Bulk operations minimally logged in this mode. This means it has written only minimal roll backing information to the log file not whole (i.e. not fully logged). The BCM page contains all the required information. See an example you can understand. Bulk logged recovery model is the best model for server performance. Because all the bulk changes have www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ 1/5
  • 2. 27/08/2012 SQL server Recovery Models and Backup types « Sql server Blog Forum been written minimally (Not fully) to the transaction log file. In bulk logged recovery model we can take all kinds of backups like full, differential and transaction Log but, the drawback is the point in time recovery (PTR)is not possible, when there is a bulk operations have done with the transaction log file. Keep in mind, in full and bulk logged recovery model the log files grow bigger until the BAC KUP LOG has done. For more clarity. See an example: Just assume 5,000 bulk operations have written in 8000 pages. In full recovery model each 5,000 bulk operations have written in 8000 pages, because all the changes have written fully in the full recovery model. But when we used bulk logged recovery model, it has written 1000 pages only ,Because SQL server has written the bulk changes to an extent wise not the page wise i.e. minimally logged operation (8 pages = 1 extent). It will help to improve the overall server performance. Now you know, Writing 8000 pages are good or 1000 pages. Note: This bulk logged model is good only for the bulk operations. Simple The name itself you can understand the answer. Simple recovery model is just simple this means SQL server will run the checkpoint every minute and truncate the transaction log file often. Mostly the log file will not grow larger. Most of the time the simple recovery model is a good choice for non production servers. Because the log file will not grow larger. Also we would not take log backups. (If you’re planning to take the log backup then don’t put in simple) In the simple recovery model the transaction log backup is not possible. We can take full and differential backups only. Now you could know answer for the following questions. What is the use of Full, Bulk logged and Simple recovery model. Which one is best? Backup Types SQL server has number of backup types. Here I am going to explain the main three types. 1. Full 2. Differential 3. Transaction log I recommend to read Paul S Randals’s backup survey post. http://www.sqlskills.com/BLOGS/PAUL/post/Importance-of-having-the-right-backups.aspx Full backup A full backup backs up the full/whole database. That backs up all the committed data. The full database backup has been done in all the recovery models. Differential backup A differential backup only backs up the changed data/extents that were modified after the full database backup has done. The DCM has tracked all the changed extents. The differential backup has been done in all the recovery models. For more clarity. See an example: Assume we are scheduled every Sunday full backup @12 am and daily differential backup 10 PM. Note: The data change daily 500 MB. Question: How much data got back up on Thursday? The student answers 500 MB. As I already told, differential database backup “backs up all the data that has changed since the last full database backup”. The answer is, Monday 500MB + Tuesday 500 MB + Wednesday 500MB + Thursday 500MB= 2000MB www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ 2/5
  • 3. 27/08/2012 SQL server Recovery Models and Backup types « Sql server Blog Forum Edit: I added these lines after I had replied the forum question SSC . So the differential backup on Thursday has all the data. That is (Monday+Tuesday+Wednesday+Thursday). It helps to bring the database online as quickly as possible. Transaction log backup A transaction log backup backs up the transaction log file. That is all the modifications/changes. The transaction log backup only possible in full and bulk logged recovery model. The transaction log backup is important to minimize data loss and log file size too. It’s very important to keep the transaction log backup as much as safe, because the restoration needs the sequence of the transaction log backup if, you deleted/missing any one of the backups then you can’t recover the whole data. I have suggested running the log backups often. It will reduce the log file size and helps to minimize your data loss. Question: How to restore the database after a disaster? (OR) What is the sequence to restore the database? Answer: Restore a full backup and followed by recent differential backup and all the log backup one by one in a sequence. For more clarity. See an example: Assume we are scheduled every Sunday full backup @12 am and daily differential backup 10 PM and an hourly log backup. The database crashed on Wednesday at 1:30 PM. Then the restoration will be on Sunday full backup+ Wednesday differential backup (Most recent) + log backup @11+@12+@1. Believe me guys, Test your backups often and keep at least two copy of the full backups safely, Because the full backup is important to restore the all other backups. This means without a full backup you can’t restore the differential and log backups. Muthukkumaran kaliyamoorthy I’m currently working as a SQL server DBA in one of the top MNC . I’m passionate about SQL Server And I’m specialized in Administration and Performance tuning. I’m an active member of SQL server C entral and MSDN forum. I also write articles in SQL server C entral. For more Click here More Posts - Website Share this 21 C omments - Leave a comment ram June 7, 2011 at 11:22 am dude,superb , very useful to understand the basic recovery model and backup types and the way which you explained s nice Muthukkumaran June 7, 2011 at 12:01 pm I wrote this post after we had a class discussion. Thanks to you dude. Anonymous June 7, 2011 at 3:43 pm Hi Muthu 1. As you said, In-case of any disaster on Wednesday @ 1:30 pm. 2. We have to perform the "Tail-Log" backup first. Then only we will have last 30 minutes transaction after the actual transaction-log hourly backup. correct ? 3. Then, we have to proceed with further Restore either (Norecovery or Standby state) Muthukkumaran June 8, 2011 at 6:01 am @Anonymous user Yep, You are right.we can take the tail log backup if, there is no damage in transaction log file.I didn't focus the restore part fully. It's just an example to understand the restoration sequence to all the newbies. www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ 3/5
  • 4. 27/08/2012 SQL server Recovery Models and Backup types « Sql server Blog Forum Thanks to reading my posts. i don't know most of my comments are from Anonymous user. Nobody is writing his name. Anonymous June 9, 2011 at 11:40 am Spot-on post.I agree with the first person comment the way you explained really superb and it's written using very simple/understandable english. keep up the good work. Great examples. BY Yardy Muthukkumaran June 9, 2011 at 5:31 pm @yardy glad you liked it.thanks To be frank i don’t know complex words.lol vinoth June 11, 2011 at 6:21 am Hi muthu, Great post. I liked this. Monday 500MB + Tuesday 500 MB + Wednesday 500MB + Thursday 500MB= 2000MB Muthukkumaran June 21, 2011 at 9:13 am So the differential backup on Thursday has all the data. That is (Monday+Tuesday+Wednesday+Thursday). It helps to bring the database online as quickly as possible. I have added these lines after i replied the forum question http://www.sqlservercentral.com/Forums/Topic1128012-391-2.aspx?Update=1 Anonymous July 9, 2011 at 9:36 am H Muthu, I am new to SQL DBA group. I have doubt here about DR, as you said the DB crashed on Wed at 1:30 PM Below is the sequential backup i have backup: Sun – Full backup @ 12:00 AM (Mid-Night) Mon – Differential Backup @ 10: PM (Night) Tue – Diff @ 10:PM (Night) Wed – DB crashed @ 1:30 PM (Afternoon) Than my question here is how come we follow restore with – Sun full backup + WED Diff because if DB crashed at 1:30 PM (Noon) on wed thn we don't have WED's diff backup (night)as DB crashed in Noon. So do we need to add tuesday's Differentail Backup. Please clarify my doubt. thanks- Pooja Muthukkumaran July 9, 2011 at 10:55 am Pooja, Yep you are right. If you have log backup you can restore that too. If you want more answer I suggest you to ask questions to SQlservercentral and MSDN forum. this post is quoted by SQL server Disaster Recovery plan « SqlserverBlogForum 9, 2011 at 2:19 pm October [...] its simple(less expensive) and good option for disaster recovery but it’s depends upon your backup strategy and recovery model. The backup restore will work for all the above three DR methods. The DBA job is keep the data [...] this post is quoted by Difference between truncating and shrinking the transaction2011 file « pm October 9, log at 3:34 SqlserverBlogForum [...] It depends upon the recovery model. [...] Myrman October 31, 2011 at 1:04 am Thank you for making your work very easy to comprehend. The topic is somewhat baffling as it is but you make it look easy. This is just what people need to read. www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ 4/5
  • 5. 27/08/2012 SQL server Recovery Models and Backup types « Sql server Blog Forum Muthukkumaran kaliyamoorthy October 31, 2011 at 7:23 pm Glad you liked it.Thanks. Deandrea Nodine November 3, 2011 at 10:29 pm Useful page and incredibly informative. Thanks for taking the time to write it and post it! Muthukkumaran kaliyamoorthy November 4, 2011 at 11:35 am Thanks Deandrea Nodine. Mellie Partible November 6, 2011 at 8:51 am You, my friend, ROC K! I found just the info I already searched everywhere and just could not locate it. What a perfect website. I have bookmarked your website: http://www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ and will check back often. Thanks for the awesome information! Muthukkumaran kaliyamoorthy November 6, 2011 at 11:01 am I’m glad you liked it. Dee Lazich February 11, 2012 at 12:58 am I don’t even understand how I finished up right here, however I assumed this publish was once great. I do not recognize who you might be however certainly you’re going to a well-known blogger should you are not already C heers! Muthukkumaran kaliyamoorthy February 11, 2012 at 11:26 am I’m glad it helps you. Thanks Dee. this post is quoted by Server Data Recovery | Data Recovery May 18, 2012 at 10:48 am [...] Server Data Store for Distribution Perform these steps for both servers: 1. … Fetch C ontent Two- phase C ommit Protocol – Wikipedia, The Free EncyclopediaTo accommodate recovery from failure (a… sform:capitalize;">Two-phase C ommit Protocol – Wikipedia, The Free EncyclopediaTo accommodate [...] © 2 0 1 2 Sql server Blog Forum A ll rights res erved - P owered by WordP res s www.sqlserverblogforum.com/2011/06/sql-server-recovery-models-and-backup-types/ 5/5