PowerShell script exchange
Post Reply
tester19
Novice
Posts: 8
Liked: never
Joined: Apr 20, 2023 7:07 pm
Full Name: tester testovac
Contact:

Any way to find size of data being backed up by an Agent?

Post by tester19 »

First, by data size I mean if you are backing a single folder with photos and they take up 5GB, I mean those 5GB. If you are backing whole C: system drive then the actual disk usage size you see in windows for C drive.

For VMs and NAS the following code seems to work. It gets that info you see in task as "used"

Image

Code: Select all

$LastSession = $Job.FindLastSession()
$LastSessionTasks = Get-VBRTaskSession -Session $LastSession
$DATA_SIZE = 0
foreach ($Task in $LastSessionTasks) {
    $DATA_SIZE += $Task.Progress.TotalUsedSize
}
----

But it just seems that there is nothing that one can do to get that info from agent based jobs.
Full backups report entire disk size as data size in session.
I started to think that maybe I just get last VBK file size, and multiple the size by some deduplication and compression info... but but even that info is not where one would expect it. Is there a way?
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: Any way to find size of data being backed up by an Agent?

Post by ronnmartin61 »

For agent backup jobs you'll need to use "Get-VBRComputerBackupJobSession" (note that "Get-VBRComputerBackupJob doesn't have a "FindLastSession" method). You'll need to do something like the following -

Code: Select all

$AgentJobSession = Get-VBRComputerBackupJobSession -Name "My Agent Job" | Sort-Object -Descending  | Select-Object -First 1
$LastSessionTasks = Get-VBRTaskSession -Session $AgentJobSession.Id
tester19
Novice
Posts: 8
Liked: never
Joined: Apr 20, 2023 7:07 pm
Full Name: tester testovac
Contact:

Re: Any way to find size of data being backed up by an Agent?

Post by tester19 »

Yeap. I am using VBRComputerBackupJobSession where needed.
What I found out so far is that it is not agent job issue its the mode of backup issue.
If its not entire computer, or an entire volume, but just selected few folders, the the size of data being backed is still reported as if the whole disk capacity of the partition.
tester19
Novice
Posts: 8
Liked: never
Joined: Apr 20, 2023 7:07 pm
Full Name: tester testovac
Contact:

Re: Any way to find size of data being backed up by an Agent?

Post by tester19 »

I tested the idea of getting the size of data from the size of last vbk file and its dedup and compress ratios.
  • In the first case it worked extremely well as both ratios were low and the size of folder being backed up was around 450MB. Though notice that the data size is reported as 159GB in GUI. The job here was setup as a specfic single folder to backup.
  • the second case ratio for dedup was extremely high, obviously based off the imagined data size of 558GB. Interesting is that the partition with the data had total size 360GB. Obviously in this case the dedup ratio is calculated to get the 558GB data size. While that was not the case in the other example. The job here was setup as file backup aiming at d:\ and excluding one folder with 250GB of data.
Dont feel like theres somewhere deeper to investigate anymore.
I guess I just settle to report size of data for filebackup mode of agents as last vbk size * 1.3 cuz that seems about right with cases I see with some safety margin. And I really just want rough estimate, if its in few MBs or GBs or 50GB.. 200GB.. 500GB.. 1TB...
tester19
Novice
Posts: 8
Liked: never
Joined: Apr 20, 2023 7:07 pm
Full Name: tester testovac
Contact:

Re: Any way to find size of data being backed up by an Agent?

Post by tester19 »

Also here is my powershell code I was using for testing.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests