SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Total backup size of backup of all databases in every month from backupset table in msdb


Total backup size of backup of all databases in every month from backupset table in msdb

Author
Message
SQL-DBA-01
SQL-DBA-01
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7958 Visits: 3551
hi,

Can you please provide a quick query to get the below requirement :
Total backup size of backup of all databases in every month from backupset table in msdb


I need to prepare a sample report to analyze the database growth of databases!

Thanks.
anthony.green
anthony.green
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23296 Visits: 6519
What have you tried so far?

And does it need to be a total of all databases per month,

E.g

200GB July 2012

Or does it need to be broke down by DB

20GB Master July 2012



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


durai nagarajan
durai nagarajan
Hall of Fame
Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)

Group: General Forum Members
Points: 3347 Visits: 2784
select distinct @@servername, convert(varchar,a.backup_start_date,101) 'Date', a.database_name 'DB Name', 
convert(decimal(7,2),round(sum(b.file_size/1024/1024/1024),3)) as 'Database Size in(GB)'
from msdb..backupset a
inner join msdb..backupfile b on a.backup_set_id = b.backup_set_id

where convert(varchar,a.backup_start_date,101) = convert(varchar,getdate(),101)
and a.database_name in ( select name from sys.databases where database_id not in(1,2,3,4))
and a.type = 'd'
and b.file_type = 'd' and is_snapshot = 0
group by a.backup_set_id, a.database_name, a.backup_start_date
order by 1--, physical_name



replace getdate with the date you want , this will list datewise, DB wise size and i have excluded sys databases.

Regards
Durai Nagarajan
SQL-DBA-01
SQL-DBA-01
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7958 Visits: 3551
select distinct @@servername 'servername', convert(varchar,a.backup_start_date,121) 'Date_time', a.database_name 'DB Name',
convert(decimal(7,2),round(sum(b.file_size/1024/1024),3)) as 'Database Size in(MB)',
s.physical_device_name
into #t1
from msdb..backupset a
inner join msdb..backupfile b on a.backup_set_id = b.backup_set_id
left join backupmediafamily s

on a.media_set_id=s.media_set_id
where DATEDIFF(d, backup_start_date, GETDATE()) <= 180
--where convert(varchar,a.backup_start_date,101) = convert(varchar,getdate(),101)
--and a.database_name in ( select name from sys.databases where database_id not in(1,2,3,4))
and s.physical_device_name like 'D:\%'
and a.type = 'd'
and b.file_type = 'd' and is_snapshot = 0
--and s.physical_device_name like 'D:\%'
group by a.backup_set_id, a.database_name, a.backup_start_date, s.physical_device_name
order by 1--, physical_name


--sp_help backupmediafamily

select distinct [db name] from #t1

--drop table #t1

select date_time, sum([Database Size in(MB)]) 'DB_Size inMB', [DB Name]
from #t1
group by date_time,[DB Name]
order by date_time


## How to modify the last select statement (using dateadd function) to add in the total backup size of databases in a single day? Please suggest

Thanks.
durai nagarajan
durai nagarajan
Hall of Fame
Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)Hall of Fame (3.3K reputation)

Group: General Forum Members
Points: 3347 Visits: 2784
select convert(varchar,date_time,101), sum([Database Size in(MB)]) 'DB_Size inMB', [DB Name]
from #t1
group by convert(varchar,date_time,101),[DB Name]
order by convert(varchar,date_time,101)



try this.

Regards
Durai Nagarajan
Lavanyasri
Lavanyasri
SSC Eights!
SSC Eights! (871 reputation)SSC Eights! (871 reputation)SSC Eights! (871 reputation)SSC Eights! (871 reputation)SSC Eights! (871 reputation)SSC Eights! (871 reputation)SSC Eights! (871 reputation)SSC Eights! (871 reputation)

Group: General Forum Members
Points: 871 Visits: 955
hi ,
This is for one week backup details ::

SELECT
CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,
msdb.dbo.backupset.database_name,
msdb.dbo.backupset.backup_start_date,
msdb.dbo.backupset.backup_finish_date,
msdb.dbo.backupset.expiration_date,
CASE msdb..backupset.type
WHEN 'D' THEN 'Database'
WHEN 'L' THEN 'Log'
when 'I' THEN 'Differential database '
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) >= GETDATE() - 7)
ORDER BY
msdb.dbo.backupset.database_name,
msdb.dbo.backupset.backup_finish_date

change the getdate() -30 , then u will get for month .
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search