-
- Enthusiast
- Posts: 69
- Liked: 11 times
- Joined: Apr 28, 2015 7:52 pm
- Full Name: Tom Lyczko
- Contact:
PowerShell to gather backup sizes per server??
VMware has a cmdlet such that one can get a list of VMs' provisioned and used disk sizes.
Does Veeam have anything PowerShell that can do something similar??
I want to nightly get a list of the VMs backed up by Veeam with the size of the daily backup size per VM and the backup date (Get-Date).
I want a csv file output that I can put into Access and calculate daily changes.
Can anyone suggest a script for this?? Or at least the proper PowerShell code to output the daily backup size per VM??
Veeam support says they don't have anything to do this, which surprised me.
What I want is this: "You can see the VMs backed up by a job by going to the statistics of the job. To do this, right click on the job and select Statistics. In the left inside you will see a list of VMs. To see the size of the backup files, go to Backup & Replication --> Backups --> Disk, right click on your Job and select "Properties". The column Backup Size will show you the size of each backup file and the date when the file was created."
I want something to output this data rather than clicking all these backups every day...I can't imagine there's not a way via PowerShell, I'm just not knowledgeable enough to know or find it but once I know what it is I can work with it...This should be something standard in the application.
Thank you, Tom
Does Veeam have anything PowerShell that can do something similar??
I want to nightly get a list of the VMs backed up by Veeam with the size of the daily backup size per VM and the backup date (Get-Date).
I want a csv file output that I can put into Access and calculate daily changes.
Can anyone suggest a script for this?? Or at least the proper PowerShell code to output the daily backup size per VM??
Veeam support says they don't have anything to do this, which surprised me.
What I want is this: "You can see the VMs backed up by a job by going to the statistics of the job. To do this, right click on the job and select Statistics. In the left inside you will see a list of VMs. To see the size of the backup files, go to Backup & Replication --> Backups --> Disk, right click on your Job and select "Properties". The column Backup Size will show you the size of each backup file and the date when the file was created."
I want something to output this data rather than clicking all these backups every day...I can't imagine there's not a way via PowerShell, I'm just not knowledgeable enough to know or find it but once I know what it is I can work with it...This should be something standard in the application.
Thank you, Tom
-
- Enthusiast
- Posts: 69
- Liked: 11 times
- Joined: Apr 28, 2015 7:52 pm
- Full Name: Tom Lyczko
- Contact:
how to get $Session.Info Backup Size PER VM PER JOB??
I found this in another forum thread, how can I make $Session.Info.BackupTotalSize become ALSO backup size PER VM??
Or anything similar??
I need a script that will look at each job and output the backup size per VM per job daily, after backups have finished.
What is the correct session variable to use??
Is there a list somewhere of session variables obtainable per VM per job per day??
Another way to put it: I need all the backup job properties per job per VM per day.
Thank you, Tom
asnp VeeamPSSnapin
$Job = Get-VBRJob -Name "Name of your job"
$Session = $Job.FindLastSession()
$Session.State
$Session.CreationTime
$Session.EndTime
$Session.Info.BackupTotalSize
$Session.BackupStats.CompressRatio
$Session.BackupStats.DataSize
$Session.BackupStats.DedupRatio
Thank you, Tom
Or anything similar??
I need a script that will look at each job and output the backup size per VM per job daily, after backups have finished.
What is the correct session variable to use??
Is there a list somewhere of session variables obtainable per VM per job per day??
Another way to put it: I need all the backup job properties per job per VM per day.
Thank you, Tom
asnp VeeamPSSnapin
$Job = Get-VBRJob -Name "Name of your job"
$Session = $Job.FindLastSession()
$Session.State
$Session.CreationTime
$Session.EndTime
$Session.Info.BackupTotalSize
$Session.BackupStats.CompressRatio
$Session.BackupStats.DataSize
$Session.BackupStats.DedupRatio
Thank you, Tom
-
- Veeam Software
- Posts: 1818
- Liked: 655 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: PowerShell to gather backup sizes per server??
Check out Mimicscript : https://github.com/VeeamHub/powershell/ ... Report.ps1
Look for function calculate-vm and calculate-job. Those basically show you all the fields you are looking for and that are shown in the B&R reports (hence the name MimicReport) (perticiular how to get the "per vm session")
Final note, there is not field that says how much one VM represents inside a single restore point (it is also not something you can look up in the gui)
Look for function calculate-vm and calculate-job. Those basically show you all the fields you are looking for and that are shown in the B&R reports (hence the name MimicReport) (perticiular how to get the "per vm session")
Final note, there is not field that says how much one VM represents inside a single restore point (it is also not something you can look up in the gui)
-
- VP, Product Management
- Posts: 7076
- Liked: 1510 times
- Joined: May 04, 2011 8:36 am
- Full Name: Andreas Neufert
- Location: Germany
- Contact:
Re: PowerShell to gather backup sizes per server??
Wrote a small example for a customer for v9.5u3
Code: Select all
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
Disconnect-VBRServer | out-null
connect-vbrserver -server dnsservername -user domain\username
Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq "Backup"})
{
$LastSession = $JobObject.FindLastSession()
$JobObject.Name
$LastSession.endtime
$LastSession.Info.Progress.TotalUsedSize
$LastSession.Info.Progress.ReadSize
$LastSession.Info.Progress.TransferedSize
Write-Host "--------------------------------"
}
-
- VP, Product Management
- Posts: 7076
- Liked: 1510 times
- Joined: May 04, 2011 8:36 am
- Full Name: Andreas Neufert
- Location: Germany
- Contact:
Re: PowerShell to gather backup sizes per server??
And again a new version that makes it more easy to look at the output (or import into Excel by copy and paste):
Code: Select all
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
Disconnect-VBRServer | out-null
connect-vbrserver -server HQ-VBR1 -user amust\aneufert
$JobsOutput = @()
Foreach ($JobObject in Get-VBRJob | ?{$_.JobType -eq "Backup"})
{
$LastSession = $JobObject.FindLastSession()
$JobOutput = New-Object -TypeName PSObject
$JobOutput | Add-Member -Name "Jobname" -MemberType Noteproperty -Value $JobObject.Name
$JobOutput | Add-Member -Name "Endtime" -MemberType Noteproperty -Value $LastSession.endtime
$JobOutput | Add-Member -Name "TotalUsedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TotalUsedSize
$JobOutput | Add-Member -Name "ReadSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.ReadSize
$JobOutput | Add-Member -Name "TransferedSize" -MemberType Noteproperty -Value $LastSession.Info.Progress.TransferedSize
$JobsOutput += $JobOutput
}
$JobsOutput | Out-GridView
Disconnect-VBRServer | out-null
-
- Enthusiast
- Posts: 69
- Liked: 11 times
- Joined: Apr 28, 2015 7:52 pm
- Full Name: Tom Lyczko
- Contact:
-
- Enthusiast
- Posts: 26
- Liked: 2 times
- Joined: Oct 09, 2013 2:30 pm
- Full Name: Rick
- Contact:
Re: PowerShell to gather backup sizes per server??
I like this script. How can it be altered also list previous days backups also?
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: PowerShell to gather backup sizes per server??
Instead of getting the latest backup session you will need to query previous sessions as well, using Get-VBRBackupSession cmdlet and its CreationTime parameter as filtering attribute. Thanks!
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes month by month
I would like to know if you can help me with the following:
How can I get the datasize and backupsize from veeam backup?
I need to obtain the report with the Data size and Backupsize month by month.
can someone help me with this?
Thanks a lot
How can I get the datasize and backupsize from veeam backup?
I need to obtain the report with the Data size and Backupsize month by month.
can someone help me with this?
Thanks a lot
-
- Veteran
- Posts: 3077
- Liked: 455 times
- Joined: Aug 07, 2018 3:11 pm
- Full Name: Fedor Maslov
- Contact:
Re: PowerShell to gather backup sizes per server??
Hi Julio,
Could you please clarify what you'll be doing with the output data?
Could you please clarify what you'll be doing with the output data?
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
Hi Julio,
You need to retrieve backups' storages to obtain this kind of information. The simplest example:
Best regards,
Oleg
You need to retrieve backups' storages to obtain this kind of information. The simplest example:
Code: Select all
$backups = Get-VBRBackup
foreach ($backup in $backups) {
$storages = $backup.GetAllStorages()
foreach ($storage in $storages) {
$storage | select @{n='Name';e={$_.PartialPath}}, @{n='DataSize';e={$_.Stats.DataSize}}, `
@{n='BackupSize';e={$_.Stats.BackupSize}}
}
}
Oleg
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
Hello! thanks for answeroleg.feoktistov wrote: ↑Jan 29, 2021 3:51 pm You need to retrieve backups' storages to obtain this kind of information.
I'm not very good with Powershell. should I copy this is a TXT and save it as .PS1 and then run it from powershell, just that? or should I modify any line?
Thanks!
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
Hi Julio,
What I shared is a general example, which allows you to query all the backups registered in VBR and retrieve Name, Backup Size and Data size properties for every restore point's storage of each backup. If you would need to add anything specific to your search, start with looking at Get-VBRBackup cmdlet guide to see which parameters are available.
Let me know if you need any further help.
Best regards,
Oleg
What I shared is a general example, which allows you to query all the backups registered in VBR and retrieve Name, Backup Size and Data size properties for every restore point's storage of each backup. If you would need to add anything specific to your search, start with looking at Get-VBRBackup cmdlet guide to see which parameters are available.
Let me know if you need any further help.
Best regards,
Oleg
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
Can someone help me with a script that can tell me the total backup size made in a month? I need to show in a report the total backup size month by month. I don't know if I can see that in the Veeam console or I can only do it with a script. I don't know much about powershell and that is why it has been difficult for me to complete this task.
Thanks a lot
Thanks a lot
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
Hi,
If you need just total data size and backup size of all entities backed up for the last month, here is a simple, yet flexible script:
I tried to describe every piece of the script as detailed as possible, but let me know please in case of any questions.
Also, I encourage you to learn Powershell deeper together with object oriented concepts.
It can make your life easier
I started my PS way with these videos.
Maybe they can be of any help to you.
Best regards,
Oleg
If you need just total data size and backup size of all entities backed up for the last month, here is a simple, yet flexible script:
Code: Select all
# Create report class with data size and backup size properties
class ReportMonthly {
[int64]$dataSize
[int64]$backupSize
# Create round methods for the properties above to round values to GBs.
[int64] RoundDataSizeGB()
{
return [Math]::Round($this.dataSize/1GB, 2)
}
[int64] RoundBackupSizeGB()
{
return [Math]::Round($this.backupSize/1GB, 2)
}
# Create class constructor to be able to compose new class instances
ReportMonthly([int64]$dataSize, [int64]$backupSize) {
$this.dataSize = [Math]::Round($dataSize/1GB, 2)
$this.backupSize = [Math]::Round($backupSize/1GB, 2)
}
}
# Create a new report class instance with values equal to 0
$report = [ReportMonthly]::New(0, 0)
# Get all storages created for the last months and add their data/backup sizes to the corresponding properties of report object.
$backups = Get-VBRBackup
$date = Get-Date
foreach ($backup in $backups) {
$storages = $backup.GetAllStorages() | where {$_.CreationTime -ge $date.AddMonths(-1)}
foreach ($storage in $storages) {
$report.dataSize += $storage.Stats.DataSize
$report.backupSize += $storage.Stats.BackupSize
}
}
# Round values of report object to GBs.
$report.backupSize = $report.RoundBackupSizeGB()
$report.dataSize = $report.roundDataSizeGB()
# Send email message with the report object
$smtpServer = "smtp.server" # your smtp server here
$from = "admin@local" # your sender address here
$to = "user@local" # your recipient address here
$subject = "Test Report" # your subject here
$message = New-Object System.Net.Mail.MailMessage $from, $to
$message.Subject = $subject
$message.IsBodyHTML = $true
$message.Body = $report | ConvertTo-Html
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
Also, I encourage you to learn Powershell deeper together with object oriented concepts.
It can make your life easier
I started my PS way with these videos.
Maybe they can be of any help to you.
Best regards,
Oleg
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
Thanks for your help I really appreciate it!
But I will have to learn Poweshell to understand. Since I copy what you sent me and it throws me a series of errors that I do not understand (lol) Sure for not knowing anything about poweshell.
I just copy what you sent me in a txt and save it as test2.ps1 and after that I run it from the powershell console (./test2.ps1) and it threw me the following:
But I will have to learn Poweshell to understand. Since I copy what you sent me and it throws me a series of errors that I do not understand (lol) Sure for not knowing anything about poweshell.
I just copy what you sent me in a txt and save it as test2.ps1 and after that I run it from the powershell console (./test2.ps1) and it threw me the following:
Code: Select all
At C:\Users\adm\Desktop\Script\test2.ps1:2 char:2
+ class ReportMonthly {
+ ~~~~~
The 'class' keyword is not supported in this version of the language.
At C:\Users\adm\Desktop\Script\test2.ps1:7 char:11
+ [int64] RoundDataSizeGB()
+ ~~~~~~~~~~~~~~~
Unexpected token 'RoundDataSizeGB' in expression or statement.
At C:\Users\adm\Desktop\Script\test2.ps1:7 char:27
+ [int64] RoundDataSizeGB()
+ ~
An expression was expected after '('.
At C:\Users\adm\Desktop\Script\test2.ps1:11 char:11
+ [int64] RoundBackupSizeGB()
+ ~~~~~~~~~~~~~~~~~
Unexpected token 'RoundBackupSizeGB' in expression or statement.
At C:\Users\adm\Desktop\Script\test2.ps1:11 char:29
+ [int64] RoundBackupSizeGB()
+ ~
An expression was expected after '('.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ReservedKeywordNotAllowed
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: PowerShell to gather backup sizes per server??
Yes, you would have to run this from at least a PowerShell v5 console, since Oleg used a class constructor.
You can find the current version installed by typing $PSVersionTable in the console.
You can find the current version installed by typing $PSVersionTable in the console.
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
yes i checked with your command an I have version 4
Name Value
PSVersion 4.0
Should I update it yes or yes? I ask because on this machine where the poweshell and veeam are installed, other scripts also run and I don't know if it affects them if the powershell version is updated
Thanks for your help
Name Value
PSVersion 4.0
Should I update it yes or yes? I ask because on this machine where the poweshell and veeam are installed, other scripts also run and I don't know if it affects them if the powershell version is updated
Thanks for your help
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
Shouldn't lead to any problems.
Just make sure you don't delete powershell v2.0 altogether as it is a requirement for Veeam Backup Server to operate.
I also wouldn't advise to install Powershell Core (version 6 or later) just yet. Our cmdlets will work there only with VBR v11.
Powershell version 5.x (5.0, 5.1 or else) is your choice. Thanks!
Just make sure you don't delete powershell v2.0 altogether as it is a requirement for Veeam Backup Server to operate.
I also wouldn't advise to install Powershell Core (version 6 or later) just yet. Our cmdlets will work there only with VBR v11.
Powershell version 5.x (5.0, 5.1 or else) is your choice. Thanks!
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
Really thank you very much fot your help.
Is there a simple command that I can run on my version of powershell 4.0 that will give me that result? the Data Size in a specific month?
Because from what I saw to install version 5.0 of powershell I must restart the server and to do so I must ask for some authorizations first.
Is there a simple command that I can run on my version of powershell 4.0 that will give me that result? the Data Size in a specific month?
Because from what I saw to install version 5.0 of powershell I must restart the server and to do so I must ask for some authorizations first.
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
Sure, here is the script simplified:
Used hashtables instead, so should be working in Powershell 4.0. Thanks!
Code: Select all
# Get all backups and current date
$backups = Get-VBRBackup
$date = Get-Date
# Construct a new hastable for monthly report
$reportMonth = @{
dataSizeGB = $report.dataSizeGB
backupSizeGB = $report.backupSizeGB
}
# Get all storages created for the last month
foreach ($backup in $backups) {
$storages = $backup.GetAllStorages() | where {$_.CreationTime -ge $date.AddMonths(-1)}
foreach ($storage in $storages) {
$reportMonth.dataSizeGB += [Math]::Round($storage.Stats.DataSize/1GB, 2)
$reportMonth.backupSizeGB += [Math]::Round($storage.Stats.BackupSize/1GB, 2)
}
}
$reportMonth = $reportMonth | select @{n='dataSizeGB';e={$_.dataSizeGB}}, @{n='backupSizeGB';e={$_.backupSizeGB}}
# Send email message with the report object
$smtpServer = "smtp.server" # your smtp server here
$from = "admin@local" # your sender address here
$to = "user@local" # your recipient address here
$subject = "Test Report" # your subject here
$message = New-Object System.Net.Mail.MailMessage $from, $to
$message.Subject = $subject
$message.IsBodyHTML = $true
$message.Body = $reportMonth | ConvertTo-Html
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
Thanks very much!
Save the file as test3.ps1 and run it. I get the following message:
Is it possible to configure that instead of sending mail, the script generates some .CSV for example on disk C?
Save the file as test3.ps1 and run it. I get the following message:
Code: Select all
Get-VBRBackup: The term 'Get-VBRBackup' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C: \ Users \ adm \ Desktop \ Script \ Test3.ps1: 2 char: 12
+ $ backups = Get-VBRBackup
+ ~~~~~~~~~~~~~
+ CategoryInfo: ObjectNotFound: (Get-VBRBackup: String) [], CommandNotFoundException
+ FullyQualifiedErrorId: CommandNotFoundException
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
Add the line below to the beginning of the script:
As for CSV file generation, in the script replace this:
With this:
Thanks!
Code: Select all
asnp VeeamPSSnapin
Code: Select all
# Send email message with the report object
$smtpServer = "smtp.server" # your smtp server here
$from = "admin@local" # your sender address here
$to = "user@local" # your recipient address here
$subject = "Test Report" # your subject here
$message = New-Object System.Net.Mail.MailMessage $from, $to
$message.Subject = $subject
$message.IsBodyHTML = $true
$message.Body = $reportMonth | ConvertTo-Html
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
Code: Select all
$reportMonth | Export-Csv -Path 'C:\report.csv' -NoTypeInformation
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
you are a genious! it worked!! Thank you very much
Now that result would be last month? There is a way that I can give you the parameters, for example: I want that same report
from January 1 to January 31?
Because for the report that they request me, I must deliver them like this, that is, data size and backup size of January, February, March ... and so on.
Now that result would be last month? There is a way that I can give you the parameters, for example: I want that same report
from January 1 to January 31?
Because for the report that they request me, I must deliver them like this, that is, data size and backup size of January, February, March ... and so on.
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
For the sake of simplicity I added a calendar date range picker to the script. Now you can choose whatever date range you like, and the report will be generated for the range selected. The limit is 366 days and can be easily amended. If you click on the full date representation in the calendar header, months view becomes available, where you can choose date ranges going by months instead of days.
Here is the whole script cleaned and adjusted:
Thanks,
Oleg
Here is the whole script cleaned and adjusted:
Code: Select all
# Add assemblies needed for UI composition
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Draw and adjust a form
$form = New-Object Windows.Forms.Form -Property @{
StartPosition = [Windows.Forms.FormStartPosition]::CenterScreen
Size = New-Object Drawing.Size 243, 230
Text = 'Select a Date'
Topmost = $true
}
$form.AutoSize = $true
$form.AutoSizeMode = 'GrowAndShrink'
$form.FormBorderStyle = 'FixedDialog'
$form.KeyPreview = $true
$form.MaximizeBox = $false
$form.Text = 'Calendar'
$form.add_Shown({$form.Activate()})
$form.add_KeyDown({
switch($_.KeyCode) {
'Escape' {$form.Close()}
'Return' {$form.Close(); $Start = $cal.SelectionRange.Start; $End = $cal.SelectionRange.End}
}
})
# Draw a calendar inside the form
$calendar = New-Object Windows.Forms.MonthCalendar -Property @{
ShowTodayCircle = $false
MaxSelectionCount = 366
}
$form.Controls.Add($calendar)
# Draw an OK button
$okButton = New-Object Windows.Forms.Button -Property @{
Location = New-Object Drawing.Point 38, 165
Size = New-Object Drawing.Size 75, 23
Text = 'OK'
DialogResult = [Windows.Forms.DialogResult]::OK
}
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)
# Draw a Cancel button
$cancelButton = New-Object Windows.Forms.Button -Property @{
Location = New-Object Drawing.Point 113, 165
Size = New-Object Drawing.Size 75, 23
Text = 'Cancel'
DialogResult = [Windows.Forms.DialogResult]::Cancel
}
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)
$result = $form.ShowDialog()
# Write the date range selected to the console
if ($result -eq [Windows.Forms.DialogResult]::OK) {
$dateStart = $calendar.SelectionStart
$dateEnd = $calendar.SelectionEnd
Write-Host "Range selected: $($dateStart.ToShortDateString()) - $($dateEnd.ToShortDateString())"
}
# Get all backups and current date
$backups = Get-VBRBackup
$date = Get-Date
# Construct a new hastable for monthly report
$reportMonth = @{
dataSizeGB = $report.dataSizeGB
backupSizeGB = $report.backupSizeGB
}
# Get all storages created for the last month
foreach ($backup in $backups) {
$storages = $backup.GetAllStorages() | where {$_.CreationTime -ge $dateStart -and $_.CreationTime -le $dateEnd}
foreach ($storage in $storages) {
$reportMonth.dataSizeGB += [Math]::Round($storage.Stats.DataSize/1GB, 2)
$reportMonth.backupSizeGB += [Math]::Round($storage.Stats.BackupSize/1GB, 2)
}
}
# Construct a new object with data size and backup size information
$reportMonth = $reportMonth | select @{n='dataSizeGB';e={$_.dataSizeGB}}, @{n='backupSizeGB';e={$_.backupSizeGB}}, @{n='DateRangeStart';e={$dateStart.ToShortDateString()}}, @{n='DateRangeEnd';e={$dateEnd.ToShortDateString()}}
# Save generated report to CSV file
$reportMonth | Export-Csv -Path 'C:\report.csv' -NoTypeInformation
Oleg
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
Thank you very much Oleg as always
Where exactly should I put the date range and in what format would it be?
If I want the datasize and backupsize of the month of January, it would be something like this, for example: 2021-01-01 2021-01-31?
Where exactly should I put the date range and in what format would it be?
If I want the datasize and backupsize of the month of January, it would be something like this, for example: 2021-01-01 2021-01-31?
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
I'm sorry now if I understood. I ran it and in the calendar I selected the month of January and it actually gave me the result. But I have a question, select the entire month of January 2021 and the result was this:
dataSizeGB backupSizeGB DateRangeStart DateRangeEnd
243.8 21.31 01-01-21 31-01-21
It seems to me that it is very little, the result should have been greater, that is, in TB
dataSizeGB backupSizeGB DateRangeStart DateRangeEnd
243.8 21.31 01-01-21 31-01-21
It seems to me that it is very little, the result should have been greater, that is, in TB
-
- Influencer
- Posts: 22
- Liked: 2 times
- Joined: Jan 29, 2021 2:02 pm
- Full Name: Julio Olalla
- Contact:
Re: PowerShell to gather backup sizes per server??
For example, I made another query from November 1, 2020 to November 30, 2020 and the result was the following:
dataSizeGB backupSizeGB DateRangeStart DateRangeEnd
800 497.3 01-11-20 30-11-20
and it seems to me that it is a bit low number because I think it should be data in TB. Maybe I am doing something wrong?
dataSizeGB backupSizeGB DateRangeStart DateRangeEnd
800 497.3 01-11-20 30-11-20
and it seems to me that it is a bit low number because I think it should be data in TB. Maybe I am doing something wrong?
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: PowerShell to gather backup sizes per server??
You mean that the size of backups created in particular month and remained till the current date is lower than it should be?
I'm asking because if you need a report on backups size total processed for the particular month regardless if they are still on repository or not - it's one thing. If you need a report on backups size created in particular month and remained until current date - it's another.
I'm asking because if you need a report on backups size total processed for the particular month regardless if they are still on repository or not - it's one thing. If you need a report on backups size created in particular month and remained until current date - it's another.
Who is online
Users browsing this forum: No registered users and 16 guests