Repository size

PowerShell script exchange

Repository size

Veeam Logoby tomcec » Tue Feb 21, 2012 10:40 am

Hello, we are using V6 (w/ patch 3) and we are trying to understand how to extract information about how much free space in repositories is left.
We are using Windows repositories and we tried with:

get-vbrbackuprepository

but for how deep we may drill down the tree of methods and properties we have not seen a way to extract this info.
Can anyone give us some hint?

Thanks so much,
Tommaso
tomcec
Novice
 
Posts: 4
Liked: never
Joined: Mon Feb 20, 2012 11:00 am
Full Name: Tommaso Cecchi

Re: Repository size

Veeam Logoby ThomasMc » Tue Feb 21, 2012 11:04 am

This is the cmdlet I use for the vPC Army Report that you can't tweak to your needs

Code: Select all
function Get-vPCRepoInfo {
[CmdletBinding()]
   param (
      [Parameter(Position=0, ValueFromPipeline=$true)]
      [PSObject[]]$Repository
      )
   Begin {
      $outputAry = @()
      [Reflection.Assembly]::LoadFile("C:\Program Files\Veeam\Backup and Replication\Veeam.Backup.Common.dll") | Out-Null
      function Build-Object {param($name, $path, $free, $total)
         $repoObj = New-Object -TypeName PSObject -Property @{
               Target = $name
               storepath = $path
               StorageFree = [Math]::Round([Decimal]$free/1GB,2)
               StorageTotal = [Math]::Round([Decimal]$total/1GB,2)
               FreePercentage = [Math]::Round(($free/$total)*100)
            }
         return $repoObj
      }
   }
   Process {
      foreach ($r in $Repository) {
         if ($r.GetType().Name -eq [String]) {
            $r = Get-VBRBackupRepository -Name $r
         }
         if ($r.Type -eq "WinLocal") {
            $Server = $r.GetHost()
            $FileCommander = [Veeam.Backup.Core.CRemoteWinFileCommander]::Create($Server.Info)
            $storage = $FileCommander.GetDrives([ref]$null) | ?{$_.Name -eq $r.Path.Substring(0,3)}
            $outputObj = Build-Object $r.Name $r.Path $storage.FreeSpace $storage.TotalSpace
         }
         elseif ($r.Type -eq "LinuxLocal") {
            $Server = $r.GetHost()
            $FileCommander = new-object Veeam.Backup.Core.CSshFileCommander $server.info
            $storage = $FileCommander.FindDirInfo($r.Path)
            $outputObj = Build-Object $r.Name $r.Path $storage.FreeSpace $storage.TotalSize
         }
         elseif ($r.Type -eq "CifsShare") {
            $fso = New-Object -Com Scripting.FileSystemObject
            $storage = $fso.GetDrive($r.Path)
            $outputObj = Build-Object $r.Name $r.Path $storage.AvailableSpace $storage.TotalSize
         }
         $outputAry = $outputAry + $outputObj
      }
   }
   End {
      $outputAry
   }
}


Usage:
Code: Select all
Get-VBRBackupRepository -Name "My Repo" | Get-vPCRepoInfo


Sample Output:
Code: Select all
storepath      : E:\Backups
FreePercentage : 63
StorageTotal   : 824.00
StorageFree    : 522.05
Target         : My Repo
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Repository size

Veeam Logoby tomcec » Tue Feb 21, 2012 12:03 pm

ThomasMc wrote:This is the cmdlet I use for the vPC Army Report that you can't tweak to your needs

Thomas, thanks for your immediate and quick reply. Works perfectly for me. I'll just try to convert the output in a sort of csv format (not actually a guru in powershell so ... it could take a while) and post it here.

Thanks again,
Tommaso
tomcec
Novice
 
Posts: 4
Liked: never
Joined: Mon Feb 20, 2012 11:00 am
Full Name: Tommaso Cecchi

Re: Repository size

Veeam Logoby ThomasMc » Tue Feb 21, 2012 12:07 pm

You could do this

Code: Select all
#Save output to CSV
Get-VBRBackupRepository -Name "My Repo" | Get-vPCRepoInfo | Export-Csv C:\Test.csv -NoTypeInformation
#Open the file with default viewer
Invoke-Expression C:\Test.csv
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell

Re: Repository size

Veeam Logoby wasawatt » Sat Jul 16, 2016 3:31 pm

Hi Thomas,
I try to follow you and I use Veeam BR9. on Windows Server 2008R2 with Powershell v4.
but unfortunately I got this error for about 'Create' method of "[Veeam.Backup.Core.CRemoteWinFileCommander]".

Code: Select all
----------------------------------------
Method invocation failed because [Veeam.Backup.Core.CRemoteWinFileCommander]
does not contain a method named 'Create'.
At line:28 char:13
+             $FileCommander =
[Veeam.Backup.Core.CRemoteWinFileCommander]::Create ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

You cannot call a method on a null-valued expression.
At line:29 char:13
+             $storage = $FileCommander.GetDrives([ref]$null) | ?{$_.Name -eq
$r.P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Attempted to divide by zero.
At line:11 char:10
                                           
-------------------------------------------

could you or everyone guide me to fix this issue.

regards and Thank you,
Wasawatt
wasawatt
Lurker
 
Posts: 2
Liked: never
Joined: Sat Jul 16, 2016 3:13 pm
Full Name: Wasawatt

Re: Repository size

Veeam Logoby v.Eremin » Mon Jul 18, 2016 3:10 pm

The workaround provided above used unsupported and undocumented approach that has ceased to exist already.

What information are you trying to get? Repository utilization? Don't you have a Veeam ONE deployed by any chance?

Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Repository size

Veeam Logoby wasawatt » Wed Aug 03, 2016 9:40 am

Hi,
I need to check to size of VM is fit with repository before create job. due to I integrate with VMware and need to create some logic to check.

for Veeam ONE i am not deploy it. I use on;y Veeam Backup & Replicate and Enterprise Manager.

Regards,
wasawatt
Lurker
 
Posts: 2
Liked: never
Joined: Sat Jul 16, 2016 3:13 pm
Full Name: Wasawatt

Re: Repository size

Veeam Logoby v.Eremin » Wed Aug 03, 2016 11:01 am

You can use this tool to get general idea on how much space will be occupied on a repository. Thanks.
v.Eremin
Veeam Software
 
Posts: 13291
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests