PowerShell script exchange
Post Reply
billcouper
Service Provider
Posts: 153
Liked: 34 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

FileShare backup license consumption and disk usage

Post by billcouper »

Our scenario is that we are beginning to provide hosted FileShare backups from public clouds. For example, we will back up a customers Azure Files data. I create a NAS backup job that saves 5 points on SSD. This job is configured to have multiple secondary copies (we keep two copies, one here and one in our remote DR site). Each customer will have one backup job, with two secondary destinations. The secondary destinations are where we will set the retention period requested by the customer.

Using PowerShell, I need to be able to report not only the FileShare license consumption, but also how much capacity on disk is being consumed by the secondary destinations. I am setting up a test customer, so that I can work out how to do the reporting. This test customer has 11 Azure Files shares being backed up in the single backup job, with the two secondary destinations configured.

I can work out the license instance consumption for each of the 11 shares and stick that into an array which allows me to easily sum the license usage of a file backup job (one file backup job equals one customer).

The bit I am stuck at is how to get the size of the backup data on disk? I've been looking into the Get-VBRNASBackupRestorePoint cmdlet but it doesn't seem to have any info about size on disk... none of the other cmdlets jump out as being especially useful to me.... how do I get the size of backup files on disk?

This is what I have so far:

Code: Select all

$FileBackupJobs = Get-VBRNASBackupJob
$FileShareLicenses = Get-VBRLicensedInstanceWorkload -License (Get-VBRInstalledLicense)
$FileShareLicenses = $FileShareLicenses | ? { $_.Type -eq 'FileShare' }

$Output = @()

foreach ($filejob in $FileBackupJobs) {
    $objFileJob = [pscustomobject]@{
        Name = $filejob.Name
        Id = $filejob.Id
        BackupObject = @()
    }
    foreach ($source in $filejob.BackupObject) {
        $objSource = [pscustomobject]@{
            Path = $source.Path
            LicenseUsage = ($FileShareLicenses | ? { $_.Name -eq $source.Path }).UsedInstancesNumber
            BackupSizeGB = 0
        }
        $objFileJob.BackupObject += $objSource
    }
    $Output += $objFileJob
}

I am trying to work out where to pull the info required to set the BackupSizeGB value of the customer
billcouper
Service Provider
Posts: 153
Liked: 34 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: FileShare backup license consumption and disk usage

Post by billcouper »

Case #05013993
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: FileShare backup license consumption and disk usage

Post by oleg.feoktistov » 1 person likes this post

Hi Bill,

Unfortunately, no supported way to do that. But, as a workaround, I would suggest the following:

Code: Select all

# This is an example for one nas backup

$backup = Get-VBRNASBackup
$nasBackup = [Veeam.Backup.Core.CNasBackup]::GetByBackupId($backup.Id)
$nasPoints = $nasBackup[0].GetNasPoints()
$nasPoints.Info.ProtectedSize 
Hope it helps,
Oleg
billcouper
Service Provider
Posts: 153
Liked: 34 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: FileShare backup license consumption and disk usage

Post by billcouper »

Thanks Oleg, I will give that a try!
billcouper
Service Provider
Posts: 153
Liked: 34 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: FileShare backup license consumption and disk usage

Post by billcouper »

Hi Oleg,

That seems to give the size of the source. It answers the question "how much data is being protected?" that I am not asking (since that only matters in terms of licensing, which I already have answer for based on the instance license consumption).

Rather, the question I need to answer is "how much disk space are the backups of this data consuming?"

Looking at $nasPoints there is this property
* $nasPoints.Info.ReadSize
That tells me how much data was read during each backup. In theory if I sum those together it is the size of the backups.... but... there must be some compression of the data? If the backups are compressed then the 'ReadSize' is invalid for calculating disk use.

I can go to the filesystem directly and find the size of the data on disk... except... there doesn't appear to be a way to programmatically identify WHERE the backups are stored on disk. I can base my data collection on assumptions, but I would rather not do that. For example... if I assume the folder the backups is stored in is the name of the job, but with spaces and brackets converted to underscores, that might work most of the time... but the first time Veeam support suggest to clone a job to resolve an issue, or an engineer deletes and recreates a job for "reasons", all of a sudden the folder name on disk changes and the assumption no longer valid... What am I even talking about here? Well, consider this...

In a normal backup job, if I want to find the size on disk, I can get that info from Veeam directly... or I can go to the filesystem and gather it that way... this is possible because the information required to do so is actually returned in the powershell objects.

Here is an example for a normal VM backup job:

Code: Select all

$StorageSize = 0
$vbrbackup = Get-VBRBackup -Name "The Name Of The Backup"
$vbrbackup.FindRepository().GetExtents() | sort Name | % {
$StorageSize += (gci "$($_.Path)$($vbrbackup.GetFullPath().Elements)" -Recurse | Measure-Object -Sum Length).Sum
}
That works because the following object properties exist
* $vbrbackup.GetFullPath().Elements
* $vbrbackup.FindRepository().GetExtents().Path

Those properties tell me, without making any assumptions, exactly where to look on disk for the backup files that may be spread across multiple extents in the SOBR.

Unfortunately, similar properties don't seem to exist for the NAS backup job object. In particular, the "GetFullPath().Elements" that identifies that name of the folder on disk which is the most critical element needed to gather the required data.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: FileShare backup license consumption and disk usage

Post by oleg.feoktistov »

Hi Bill,

Yes, you are right. I don't see any property in our .NET classes, which would keep backed up size data and I assume we don't have one as in file backup properties in the UI only original size is shown.
Now, as for other methods of getting this info. You could try the same approach you do for your VM backups with slight amendments:

Code: Select all

$StorageSize = 0
$nasBackup = Get-VBRNASBackup -Name 'File Backup Job'
$vbrbackup = [Veeam.Backup.Core.CBackup]::Get($nasBackup.Id)
$backupPath = $vbrbackup.DirPath.ToString()
$vbrbackup.FindRepository().GetExtents() | sort Name | % {
$StorageSize += (gci "$($backupPath)" -Recurse | Measure-Object -Sum Length).Sum
}
Let me know if it has helped,
Oleg
billcouper
Service Provider
Posts: 153
Liked: 34 times
Joined: Dec 18, 2017 8:58 am
Full Name: Bill Couper
Contact:

Re: FileShare backup license consumption and disk usage

Post by billcouper »

$vbrbackup = [Veeam.Backup.Core.CBackup]::Get($nasBackup.Id)
$backupPath = $vbrbackup.DirPath.ToString()

^ That will help a lot. Thanks!
DanielJ
Service Provider
Posts: 241
Liked: 44 times
Joined: Jun 10, 2019 12:19 pm
Full Name: Daniel Johansson
Contact:

Re: FileShare backup license consumption and disk usage

Post by DanielJ »

Borrowing this thread for a feature request. The lack of availability of storage info for NAS backups is disappointing. I'm sure others than me would need that info for internal billing. The method above works for finding out where the backups are, but that's not much help when they are stored on a hardened repository. We are in the process of making all our repositories hardened, even if immutability is not available for NAS backups (yet?). I was happy to finally get rid of the legacy product that has done this kind of backups for us until now, but I couldn't imagine that basic info such as disk usage would not be easily available. It looks like these are my options:

- Keep a separate non-hardened repository just for this purpose, and use the above method to get disk usage.
- Manually log in to the console of the repository with NAS backups each month and collect billing numbers.
- Enable ssh (or install something else) on the hardened repository that would make it possible to have a script connect to it just to get this info - which would go against the hardened design.

So can we please have this essential information available via Powershell in a future release?
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: FileShare backup license consumption and disk usage

Post by oleg.feoktistov » 1 person likes this post

Hi Daniel,

Thanks, noted. Need to check with my NAS-responsible colleague though. We are core logic dependant here, so if this info will be written to our DB, we will be able to obtain it one way or another, which makes it a basis for building a powershell function. I’ll let you know how it goes.

Best regards,
Oleg
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: FileShare backup license consumption and disk usage

Post by oleg.feoktistov » 1 person likes this post

Turns out adding backup and data size metrics to NAS backup view is planned for v12. It just that it didn't make it to beta.
As soon as it is added, I can research a workaround and share it here after GA. Thanks!
DanielJ
Service Provider
Posts: 241
Liked: 44 times
Joined: Jun 10, 2019 12:19 pm
Full Name: Daniel Johansson
Contact:

Re: FileShare backup license consumption and disk usage

Post by DanielJ »

Sounds great! Thank you!
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: FileShare backup license consumption and disk usage

Post by oleg.feoktistov »

Hi all,

It's been a while, but I figured I'd also reference the workaround to finding nas share protected (backup) and read (data) sizes here.

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 12 guests