First of all make sure backup compression is enabled on the SQL Server. You can execute below query to check the backup compression.
select name,[description],value_in_use from sys.configurations where name like '%backup%'
Execute below script to check the compressed backup file size and backup compression ratio.
Declare @FromDate as datetime
-- Specify the from date value
set @FromDate = GETDATE() -1
SELECT
CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS SQLServerName,
msdb.dbo.backupset.database_name,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
WHEN 'I' THEN 'Differential'
END AS backup_type,
msdb.dbo.backupset.backup_start_date,
msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
DATEDIFF (SECOND, msdb.dbo.backupset.backup_start_date, msdb.dbo.backupset.backup_finish_date) 'Backup Elapsed Time (sec)',
msdb.dbo.backupset.compressed_backup_size AS 'Compressed Backup Size in KB',
(msdb.dbo.backupset.compressed_backup_size/1024/1024) AS 'Compress Backup Size in MB',
CONVERT (NUMERIC (20,3), (CONVERT (FLOAT, msdb.dbo.backupset.backup_size) /CONVERT (FLOAT, msdb.dbo.backupset.compressed_backup_size))) 'Compression Ratio',
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
END AS backup_type,
msdb.dbo.backupset.backup_size,
msdb.dbo.backupmediafamily.logical_device_name,
msdb.dbo.backupmediafamily.physical_device_name,
msdb.dbo.backupset.name AS backupset_name,
msdb.dbo.backupset.description
FROM msdb.dbo.backupmediafamily
INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id
WHERE
CONVERT(datetime, msdb.dbo.backupset.backup_start_date, 102) >= @FromDate
AND msdb.dbo.backupset.backup_size > 0
ORDER BY
msdb.dbo.backupset.database_name,
msdb.dbo.backupset.backup_finish_date
Thanks a lot this is helpful. I have one question: Is there a way to tell if compression is used or not…Like if we can have one column that tells compressed or not (1 or 0)
You can restoer headeronly command
you can use restore headeronly command or check the backup system table to check that
backupmediaset.is_compressed =1
Pingback: SQL SCRIPTS DECEMBER 24, 2014 How to restart an Interrupted Database Restore in SQL Server? Steps to restart an Interrupted Database Restore in SQL Server There may scenario when you are restoring VLDB database backup and the restore database command inte
Pingback: SQL SCRIPTS DECEMBER 24, 2014 How to restart an Interrupted Database Restore in SQL Server? Steps to restart an Interrupted Database Restore in SQL Server There may scenario when you are restoring VLDB database backup and the restore database command inte
Pingback: SQL SCRIPTS DECEMBER 24, 2014 How to restart an Interrupted Database Restore in SQL Server? Steps to restart an Interrupted Database Restore in SQL Server There may scenario when you are restoring VLDB database backup and the restore database command inte
use msdb
select database_name,type,DATEPART(day,backup_start_date),sum((dbo.backupset.compressed_backup_size)/(1024*1024*1042)) from dbo.backupset where
–dbo.backupset.database_name=’HOHaj070113′ and
–type=’I’ and
backup_start_date >= ‘20140601’ group by cube(database_name, DATEPART(day,backup_start_date),type) order by 1 desc ,2 desc,3 desc
Great Information! I got my solution here thanks for sharing. I have found another helpful article regarding backup compression in sql server. see here: http://www.sqlserverlogexplorer.com/advantages-of-backup-compression/
Pingback: SQL Server – Database Backup Compression | Learning in the Open