This post is about how to calculate the storage needs for the configured Veeam Backup Jobs. When you edit or create a new backup job in Veeam Backup and Replication. You can use the Check Space button to verify if there is enough space to write the backup to disk:

But is it possible to get this values via Powershell. The answer is yes. Before you can calculate these values you need to know the formula which Veeam uses to calculate the storage needs. This is the formula:

Backup size = C * (F*Data + R*D*Data)

Replica size = Data + C*R*D*DataData = sum of processed VMs size (actually used, not provisioned)

C = average compression/dedupe ratio (depends on too many factors, compression and dedupe can be very high, but we use 50% – worst case)

F = number of full backups in retention policy (1, unless backup mode with periodic fulls is used)

R = number of rollbacks (or increments) according to retention policy (14 by default)

D = average amount of VM disk changes between cycles in percent (we use 10% right now, but will change it to 5% in v5 based on feedback… reportedly for most VMs it is just 1-2%, but active Exchange and SQL can be up to 10-20% due to transaction logs activity – so 5% seems to be good average)

This formula comes from the Veeam Communities: http://www.veeam.com/forums. There is a lot of good information there. So make sure to visit it once in a while .

So now we know the formula, the next step will be to find the data to fill the parameters to calculate the disk space requirements. It’s time to start a script editor to write some Powershell code. First we start to make sure the Veeam Powershell snapin is loaded:

if((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null){ Add-PSSnapin "VeeamPSSnapIn" }

The following variables are necessary to calculate the disk space needed to save the job to disk. First we need to the local disk info so we can return the freespace of the partition where the job will be written to. The avgcr variable is equal to **C **in the formula. The numFull variable, well you can guess where that stands for. This variable equals the **F** in the formula. The retaincycles variable equals the **R **in the formula. The last variable,

avgdiskchanges equals the **D **in the formula.

$diskinfo = Get-WmiObject Win32_logicaldisk $options = $vbrjob.GetOptions() $avgcr = "50" $numFull = $options.FullBackupFrequency $retaincycles = $options.RetainCycles $avgdiskchanges = "5"

The script that will do the magic:

if((Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null){ Add-PSSnapin "VeeamPSSnapIn" } $DestinationStorage = @() foreach($vbrjob in (Get-VBRJob | Sort Name)){ $Details = "" | Select JobName, Driveletter, TotalVMs, TotalCapacityinGB, FreespaceinGB, SourceDatainGB, EstimatedFullBackupSizeinGB, EstimatedRequiredSpaceinGB, StorageNeededinGB $diskinfo = Get-WmiObject Win32_logicaldisk $options = $vbrjob.GetOptions() $avgcr = "50" $numFull = $options.FullBackupFrequency $retaincycles = $options.RetainCycles $avgdiskchanges = "5" $driveLetter = $vbrJob.Info.TargetDir.Split("\")[0] $partition = $diskinfo | Where {$_.DeviceID -eq $driveLetter} $TotalCapacity = [math]::round($partition.Size / 1GB, 2) $FreeSpace = [math]::round($partition.FreeSpace / 1GB, 2) $JobSize = [math]::round($vbrjob.Info.IncludedSize / 1GB, 2) #TotalSize in Veeam Console $FullBackupSize = $jobSize / 2 $JobMath = "{0:P0}" -f $avgcr / 100 * ($numFull * $JobSize + $retaincycles * ("{0:P0}" -f $avgdiskchanges / 100 * $JobSize)) $JobMath2 = [math]::round($JobMath, 2) $Details.JobName = $vbrjob.Name $Details.Driveletter = $driveLetter $Details.TotalVMs = ($vbrJob.GetObjectsInJob()).Count $Details.TotalCapacityinGB = $TotalCapacity $Details.FreespaceinGB = $FreeSpace $Details.SourceDatainGB = $JobSize $Details.EstimatedFullBackupSizeinGB = $FullBackupSize $Details.EstimatedRequiredSpaceinGB = $JobMath2 + $JobSize $Details.StorageNeededinGB = ($JobMath2 + $JobSize) - $FreeSpace $DestinationStorage += $Details } $DestinationStorage

And it’s output:

I hope you like this script and if you have any questions please leave a comment.

## One thought on “Veeam: Calculate Destination Storage Needs with Powershell”