Last week we covered five reasons why log shipping should be used. I got a great question that I thought should be answered here in a short blog post. The question is “how do you configure transactional log shipping to include compression when taking the transactional log backups?”
The Missing Question
First, a better question is “should we be compressing our SQL Server Backups?” In a second we will address log shipping, but first I wanted to just focus on compressing backups. The answer is “it depends” (typical DBA response). There is CPU overhead for utilizing compression. We will not focus too much on this here as you can enable resource governor to limit CPU usage for your backups.
Today, we will focus on capacity and misleading storage saving results due to enabling backup compression. Looking at a traditional DBA role, you might have exposure to view your server, drives, and the size of the backups. Therefore, taking a compressed backup leads you to likely see less storage being used for the backup file compared to other backups of the same database. This is typically the goal for backup compression to reduce storage space consumed by backups.
Another question you should be asking yourself is, “What storage system is being used for your SQL Server backups?” For example, storage access networks (SAN) might have its own compression and native SQL Server backup compression might hurt the impact of the SAN’s compression, which could cause more RAW storage to be used. Therefore, there really isn’t a silver bullet to always use SQL Server backup compression in every environment. You need to understand if there is any compression built into the storage used for your backups, and understand how backup compression impacts the storage system before deciding to utilize backup compression.
Compress Log Shipping Backup
Okay, now that we got our disclaimer
common real-world mistake out of the way. Here is how you would enable backup compression for transactional log shipping.
Enabling Compression with T-SQL Backups
Enabling backup compression with T-SQL is as simple as just adding the compression option. The following is a common example of backing up a database with compression.
[code language=”sql”] BACKUP DATABASE [LSDemo] TO DISK = N’c:\somewhere\LSDemo.bak’ WITH COMPRESSION [/code]
Enable Compression by Default
If all of your backups for an instance of SQL Server go to storage where utilizing native SQL Server compression provides improvement, then you can consider enabling compression by default. Therefore, all backups taken on this instance of SQL Server would then use backup compression by default unless another option was given during the T-SQL execution of the backup command.
EXEC sys.sp_configure N’backup compression default’, N’1′
RECONFIGURE WITH OVERRIDE