0% found this document useful (0 votes)
18 views

Differential Database Backups in SQL Server

Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Differential Database Backups in SQL Server

Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Differential Database Backups in SQL Server

By : Ashish Kumar Mehta

Nov 19, 2008

In this fast moving world, data is the heart & soul of any enterprise. As the business is

expanding many organizations around the world have adopted a 24x7 business model to

support and run their businesses. In a 24x7 business model data changes happen around the

clock, thereby increasing the demand for database backups. Taking full database backup is a

good practice however this consumes lot of system resources thereby slowing responses to

front end applications which are using the databases. Moreover a full database backup takes a

lot of time to complete especially for very large databases. In order to reduce the database

backup duration and also to safeguard the data, Database Administrators can take Differential

Backups of their databases.

Different types of SQL Server Database Backups


There are different types of SQL Server Database Backups available depending upon the

Recovery Model of the Database chosen by DBA. To know more about recovery models in SQL

Server you can refer to my previous article titled Database Recovery Models in SQL Server. The

different types of database backups in SQL Server are Full, Differential, Transactional Log, Full

File Backup etc. The method which the Database Administrator should choose to backup

databases depends on Recovery Model and how fast the database backup needs to be

completed.

What Does Differential Database Backups Do?


Differential database backups basically contain changes which were made to the database

since the last full backup. A differential backup usually takes lesser time to complete as it

contains only the changes (delta) which has happened to the database since the very last full

backup. It is much faster when compared to full database backups. When you have very large

databases then you should be using this backup strategy to reduce the work loss and it should

be scheduled at lesser time intervals when compared to full backups. In the event of a

disaster, a differential database backup alone will not help you to recover the database. You

need to have transactional database backups available to achieve the point in time recovery.

In this article we will see how to take differential database backups using SQL Server
Management Studio and how to take differential backups using TSQL code.

How to take Differential Database Backups using SQL Server Management


Studio
Let us see the steps which you need to perform in order to take the differential backup of

AdventureWorks database. However the initial backup of the database should always be a Full

Backup. In the Back up Database Dialog box you have the option to choose Full, Differential,

Transaction log or File and File Group backups.

1. Once you are connected to the instance of SQL Server Database Engine, in the object

explorer click on the server name node and expand it.

2. Expand the Databases Node.

3. In this article we will be see the steps which you need to follow to take the differential

backup of AdventureWorks database. Using Differential Backup strategy you can even take the

database backup of system databases expect for Tempdb and Resource databases.

4. To take differential backup of AdventureWorks database you need to right click the

AdventureWorks database and point to Tasks and then click on Back Up…. as shown in the

below snippet.
5. Once you click on Back up… option in the popup window it will open up Back Up Database

dialog box.

6. In the database drop down list, verify that database name selected is AdventureWorks. Here

you can optionally change the name to a different database if you would like to perform the

differential backup of another database. Using differential backup strategy you can perform

differential backup for databases in any of the Recovery Models (Full, Bulk-Logged or Simple).

To know more about Recovery Models in SQL Server you can refer to my previous article titled

Database Recovery Models in SQL Server.

7. Next step will be to select Differential as the value for Backup type in the drop down list.

Make sure that “Copy Only Backup” option is not checked.

8. By default, Backup component Database option will be selected for AdventureWorks

database.

9. Next you can provide values for Name & Description fields as appropriate.
10. As you could see in the above snippet that there is an option to provide the Backup set

expire days. You could see that the value provided for Backup set will expire is 0. This is

because we never want the backups to expire. However, you can provide any value between 0

and 99999 days for backup set expire.

11. Next step will be to choose differential database backup destination by selecting either of

the two options Disk or Tape. Click on Add… button to open up Select Backup Destination

dialog box and specify the location where you want the differential backups of AdventureWorks

to be saved. Click OK to save the changes as shown in the snippet.


12. In order to view or select the advanced options, click Options in the select a page pane.
13. Under Overwrite Media section, there are two options available namely Back up to the

existing media set & Back up to a new media set, and erase all existing backup sets. In this

article we have to select Append to the existing backup set option.

14. Next under Reliability section there are three options available to choose namely Verify

backup when finished, Perform checksum before writing to media and Continue on error. Here

you need to select Verify backup when finished option as we want the backups to be verified

for any error once they are completed.

15. If you are performing transactional log backup then Transaction log section will be enabled

where you can choose one of the options available namely; Truncate the transaction log or

Back up the tail of the log, and leave the database in the restoring state.

16. Next under compression section, choose the appropriate backup compression settings. In

SQL Server 2008 Enterprise Edition and later backup compression feature is available. If you

want to take the database backup utilizing backup compression feature then you can select

the option from the drop down list. To know more about Data Compression Feature in SQL

Server 2008 you can refer to my previous article titled How to configure & use Database

Backup Compression Feature of SQL Server 2008.

17. Finally click OK to take the differential database backup of AdventureWorks database.

How to take Differential Database Backups using TSQL Code


Execute the below TSQL code to take the differential database backup of AdventureWorks

databases using the database backup compression feature.

USE master
GO

BACKUP DATABASE AdventureWorks


TO DISK = N'D:\DatabaseBackups\AdventureWorks_Diff.bak'
WITH DIFFERENTIAL, COMPRESSION
GO
Advantages of Differential Database Backups

 Differential Backups usually compete in lesser time when compared to Full Backups.

The duration depends upon the number of extents which got changes since the last full

backups. A differential backup basically takes the backup of changed extents.

 Storage space required for differential backups is comparatively less when compared

to the space required for full backups because in differential backup only changed

extents are backed up.

 Restoration of database is much faster as DBA needs to first restore the full backup

using NORECOVERY and then they need to restore the latest differential backup with

NORECOVERY and then if you have any transactional logs then they need to be

restored in the same order of backup with NORECOVERY except for the last

transactional log which needs to be restored with RECOVERY option.

Disadvantages of Differential Database Backups

 Point in time recovery of the database may not be possible always if the differential

backups available are many hours prior to the time of disaster.

 It is recommended to have transactional log backups taken at shorter time intervals

along with differential backups to achieve point in time recovery.

 If there are lots of data changes happening then there could be scenarios when

differential backups are more or less of same size that of full backups.

Conclusion
Using differential backup strategy database administrators can take database backups quickly

without consuming lot of system resources especially when backing up very large databases.

However it is advised to use a combination of differential and transactional log backups for

larger databases to safeguard the database and this also helps database administrators to

perform database restores more quickly when they need to perform a disaster recovery

exercise.

You might also like