SQL Server: Compress SQL Server Backups using Native Windows Tool

SQL Server 2008 has backup compression built-in, but for SQL Server 2005 and below, you can compress backups using makecab from the command line or xp_cmdshell. Makecab even has a better compression ratio than gzip and does not require additional software to be installed on the server.

makecab D:\backups\dbname.bak D:\backups\dbname.cab

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in SQL Server
One comment on “SQL Server: Compress SQL Server Backups using Native Windows Tool
  1. Rajneesh says:

    What if we do not know the file name as it's getting generated at run time?

    Like there is a variable which store file name so is the below syntax will work ?

    @file_name – raj.xls

    makecab @file_name D:backupsdbname.cab ?

Leave a Reply

Your email address will not be published. Required fields are marked *

*