Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

SQL Server 2008 : Managing Backups - Backup Compression

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
7/9/2011 11:33:45 AM
Backup compression is a long-awaited feature that was added in SQL Server 2008. Prior to SQL Server 2008, you had to purchase third-party tools in order to achieve backup compression. You can only create a compressed backup using the Enterprise Edition of SQL Server 2008; however, restoring a compressed backup is supported in all editions of SQL Server 2008.

By default, backup compression is turned off at the server level. To change the default configuration for backup compression, you can use the sp_configure stored procedure with the 'backup compression default' parameter. You can specify value of '1' to enable the default behavior for all backups to be compressed and specify '0' to disable default compression. You can run the code in Listing 1 to enable default compression.

Example 1. Code to Enable Default Compression
USE master
GO

EXEC sp_configure 'backup compression default', '1';
RECONFIGURE WITH OVERRIDE;

You can override the default behavior for backup compression by specifying WITH COMPRESSION or WITH NO_COMPRESSION when issuing the backup statement. Listing 2 shows the syntax to create a backup on the AdventureWorks2008 database both with and without compression.

Example 2. Syntax to Create a Backup with and Without Compression
USE master
GO

PRINT '----------AdventureWorks2008 With Compression----------'

--Create a full backup with compression
BACKUP DATABASE AdventureWorks2008
TO DISK = 'C:\Backups\AdventureWorks2008_C.bak'
WITH COMPRESSION

GO

PRINT Char(13) + '----------AdventureWorks2008 No Compression----------'

--Create a full backup with no compression
BACKUP DATABASE AdventureWorks2008
TO DISK = 'C:\Backups\AdventureWorks2008_NC.bak'
WITH NO_COMPRESSION

GO

As you can see in Figure 1, a backup using compression completes more quickly because the backup file is smaller and requires less IO. The compressed backup completed in 8.192 seconds averaging 22.045 MB per second, while the non-compressed backup completed in 13.209 seconds averaging only 13.672 MB per second.

Figure 1. Backup results using compression vs. no compression

The increased backup speed also increases the CPU required to process the backup, which could impact other operations on the server while the backup is being performed. If a compressed backup has a negative impact on concurrent processes, you can use the Resource Governor to limit the CPU used by the backup process.

There are a couple of factors that determine the amount of space you will save by using backup compression. For example, text data compresses a lot more than the other data types, and encrypted data hardly compresses at all. Also, if you are using compressed tables, you will not benefit much by using backup compression. The backupset table in the msdb holds the backup size and the compressed backup size, so you can determine the amount of space you are actually saving by using backup compression. Listing 3 shows a sample query you can use to determine the amount of compression you are achieving by using backup compression.

Example 3. Code to Determine the Compression Percentage per Backup
SELECT database_name,
backup_finish_date,
1 - (compressed_backup_size/backup_size) PercentCompressed
FROM msdb.dbo.backupset
WHERE backup_size > compressed_backup_size
Other -----------------
- BizTalk 2009 : BizTalk Endpoint Management (part 2) - Endpoint Virtualization & Operation Versioning
- BizTalk 2009 : BizTalk Endpoint Management (part 1) - The Problem with WSDL
- SharePoint 2010 : Farm and Application Configuration (part 2) - Creating Search Applications & Configuring the Search Application
- SharePoint 2010 : Farm and Application Configuration (part 1) - Farm-Wide Search Settings & Managing Crawler Impact Rules
- SharePoint 2010 : Search Server 2010 and FAST Search - Search Architecture
- Microsoft Dynamics AX 2009 : Application Model Elements (part 3) - Presentation Model Elements
- Microsoft Dynamics AX 2009 : Application Model Elements (part 2) - Value Type, Database, and Data Association Model Elements
- Microsoft Dynamics AX 2009 : Application Model Elements (part 1) - Operational and Programming Model Elements
- Microsoft Dynamics AX 2009 : The MorphX Development Environment - Developing with MorphX
- Windows Server 2008 R2 : Secure Folders and Files (part 2) - Turn On BitLocker
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server