Thursday, 5 May 2011

SQL Server 2008 Backup Compression.

A brief overview of using SQL Server 2008's built in backup compression.

First Note:
The first point to note is that backup compression is a new feature in SQL Server 2008 and is not available in earlier versions. (However there are a number of non-Microsoft products to compress backups for earlier versions of SQL Server.)
By default, this feature is turned off at the SQL Server Instance level. See here on how to configure SQL Server 2008 to complete backup compression.

Overview:
Backup Compression can reduce the size of your backups by a third. The size of the resulting compressed backup depends upon several factors such as data types - see SQL Server Books Online for a more complete explanation.

Considerations in the use of Backup Compression:
There are a number of considerations to be aware of that need to be thought about before embarking upon backup compression.

Restrictions:
  • Compressed and uncompressed backups cannot co-exist in a media set.
  • Previous versions of SQL Server cannot read compressed backups.
  • NTbackups cannot share a tape with compressed SQL Server backups.

Performance Impact of Compressing Backups:
  • Benefit: Compressing a backup typically requires less device I/O and consequently usually increases backup speed.
  • Possible risk: Compression significantly increases CPU usage, CPU usage by the compression process might impact concurrent operations. (Use of the Resource Governor may help when running backups in managing CPU usage.)

Calculating the effect of compressing your backup/s:
Once you have created a compressed backup (See here for a step by step guide to setting up compressing backups), use the script below in SSMS's query window to investigate the differences between your compressed and uncompressed backup. (This is taken from the following website: http://sqlcat.com/technicalnotes/archive/2008/04/21/tuning-the-performance-of-backup-compression-in-sql-server-2008.aspx )

SELECT
b.database_name 'Database Name',
CONVERT (BIGINT, b.backup_size / 1048576 ) 'UnCompressed Backup Size (MB)',
CONVERT (BIGINT, b.compressed_backup_size / 1048576 ) 'Compressed Backup Size (MB)',
CONVERT (NUMERIC (20,2), (CONVERT (FLOAT, b.backup_size) /
CONVERT (FLOAT, b.compressed_backup_size))) 'Compression Ratio',
DATEDIFF (SECOND, b.backup_start_date, b.backup_finish_date) 'Backup Elapsed Time (sec)'
FROM
msdb.dbo.backupset b
WHERE
DATEDIFF (SECOND, b.backup_start_date, b.backup_finish_date) > 0
AND b.backup_size > 0
ORDER BY
b.backup_finish_date DESC

An uncompressed backup has a compression ratio of 1. The higher the compression ratio, the greater the space saving. Databases using the Transparent Database Encryption (TDE) feature of SQL Server 2008 may not see as high backup compression ratios.


No comments:

Post a Comment