PowerShell script exchange
Post Reply
infosys.sari
Lurker
Posts: 2
Liked: never
Joined: Jun 05, 2023 10:34 am
Full Name: Mustafa SARI
Contact:

Generating Monthly Report: backed up data size per VM

Post by infosys.sari »

Hello,
We can see these details day by day when we take report of backup jobs in HTML format.
What i want to collect is transferred data size from virtual environment to Veeam Proxy server for each VM for each day in a month.
If it's possible, i want to collect written data size (after dedup and compression) per vm as another report.
Would you please guide me to create a powershell script for this requirement?
Thanks.

Report1:
VM_Name, Read_data_DAY_1, DAY_2, ....DAY31
VM1, 100 Gb, 10 Gb, ..., 50 Gb.
VM2,
......
VM10

Report2:
VM_Name, Transferred_data_Day_1, day_2, ....day31
VM1, 10 Gb, 1 Gb, ...., 5 Gb.
VM2,
......
VM10
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Generating Monthly Report: backed up data size per VM

Post by oleg.feoktistov » 2 people like this post

Hi Mustafa,

Apologies, I must have missed your topic. Transferred, Read, Processed etc. sizes are properties of a session and task session object. Backup size, compression and dedup ratios are properties contained in a storage object. To get some of these metrics you could start with querying a backup, a list of restore points for it and then correlating restore points with task sessions and storages (vbk, vib). At that point you can pull any of this data for the time range that you need. For example, that's how I would list all the restore points created for the backup specified with Transfered and Backup sizes in GB and CreationTime:

Code: Select all

$backup = Get-VBRBackup -Name 'Backup Job 1'
$sessions = Get-VBRBackupSession | where {$_.JobId -eq $backup.JobId}
$rps = Get-VBRRestorePoint -Backup $backup
foreach ($rp in $rps) {
  $session = $sessions | where {$_.Id -eq $rp.JobRunId}
  $taskSessions = Get-VBRTaskSession -Session $session
  $taskSession = $taskSessions | where {$_.ObjectId -eq $rp.ObjectId}
  $storage = $rp.FindStorage()
  $stats = $storage.Stats
  $roundedTransferedSize = [Math]::Round($taskSession.Progress.TransferedSize/1GB, 1)
  $roundedBackupSize = [Math]::Round($stats.BackupSize/1GB, 1)
  $rp | select Name, @{n='TransferedSizeGB';e={$roundedTransferedSize}}, @{n='BackupSizeGB';e={$roundedBackupSize}}, `
  CreationTime

}
Best regards,
Oleg
DanielJ
Service Provider
Posts: 200
Liked: 32 times
Joined: Jun 10, 2019 12:19 pm
Full Name: Daniel Johansson
Contact:

Re: Generating Monthly Report: backed up data size per VM

Post by DanielJ »

I wonder how this can be adapted to work with agent backups. I get the sessions with Get-VBRComputerBackupJobSession (instead of Get-VBRBackupSession), but none of those sessions has an Id which matches the JobRunId for any of the restore points for the agent job.
infosys.sari
Lurker
Posts: 2
Liked: never
Joined: Jun 05, 2023 10:34 am
Full Name: Mustafa SARI
Contact:

Re: Generating Monthly Report: backed up data size per VM

Post by infosys.sari »

Hello Oleg,
Thank you for your response. it contains data i need but i need more historic data.
We keep restore points very short (2 weeks) to consume less storage space but we need data for the last 30 days.
That data still exist on veeam database. Because we can view it when we have created job report from the veeam console gui.
how can we substitude below line to reach whole data?
$rps = Get-VBRRestorePoint -Backup $backup
Thanks.
Mustafa.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Generating Monthly Report: backed up data size per VM

Post by oleg.feoktistov »

Hi Mustafa,

You can then remove -Backup parameter. This will get you all of the restore points. Then you could filter them out by creation time if necessary. For example, to get all the restore points for the last month you would apply this filter:

Code: Select all

$currentDate = Get-Date
Get-VBRRestorePoint | where {$_.CreationTime -ge $currentDate.AddMonth(-1)} | sort -Property CreationTime -Descending
Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests