PowerShell script exchange
Post Reply
Refruit
Service Provider
Posts: 34
Liked: 2 times
Joined: Feb 27, 2020 6:38 am
Contact:

Get-VBRBackup changes v11 to v12 and Offloading S3

Post by Refruit »

Hello,

we were using the following script to identify the lastest *.vbk which was marked as monthly GFS and offload this into S3:

Code: Select all

Import-Module Veeam.Backup.PowerShell -WarningAction SilentlyContinue 3>$null

Function Test-MaxSobrSessions {
    Param(
        [Int]$MaxSessions
    )
    $NumSessions = ([Veeam.Backup.Core.CBackupSession]::GetByJobType([Veeam.Backup.Model.EDbJobType]::ArchiveBackup) | Where-Object {$_.JobName -like 'SOBR*' -and $_.State -eq 'Running'}).count
    If ($NumSessions -ge $MaxSessions) {
        return $True
    } Else {
        return $False
    }
}

$Backups = (Get-VBRBackup -Name "xxx","yyy").GetAllStorages() | Where-object {($_.Filepath -like "*.vbk") -and ($_.GfsPeriod -ne "None")}
$Backups | Group-Object -Property {$_.PartialPath.Elements[0] -ireplace '^([\w\-]+)\..*', '$1'} | ForEach-Object {$_.Group | Sort-Object -Property CreationTime -Descending | Select-Object -Last 1}

ForEach ($Backup in $Backups) {
    While ((Test-MaxSobrSessions -MaxSessions 7)) {
        Start-Sleep -Seconds 60
    }
    $BackupFile = Get-VBRBackupFile -Id $Backup.Id
    $null = Start-VBROffloadBackupFile -BackupFile $BackupFile -ThisBackup -RunAsync
}
It was working flawlessly within VBR v11. But i think this won't work with v12 as the "GetAllStorages()" from Get-VBRBackup is just empty.
Does anybody know why and what has been changed or tell me how i can get my script back working?

Regards
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Get-VBRBackup changes v11 to v12 and Offloading S3

Post by oleg.feoktistov »

Hi,

Most likely it won't work in v12 because backup objects now have separate meta (true per-vm). It means that both new backups created in v12 and existing backups upgraded to a new format will now have child backups for each machine.
So to make your script work again, try amending these lines so that you search for child backups before calling GetAllStorages() method:

Code: Select all

$Backups = Get-VBRBackup -Name "xxx","yyy"
$childBackups = $Backups.FindChildBackups()
$storages = $childBackups.GetAllStorages() | Where-object {($_.Filepath -like "*.vbk") -and ($_.GfsPeriod -ne "None")}
$storages | Group-Object -Property {$_.PartialPath.Elements[0] -ireplace '^([\w\-]+)\..*', '$1'} | ForEach-Object {$_.Group | Sort-Object -Property CreationTime -Descending | Select-Object -Last 1}
Best regards,
Oleg
Refruit
Service Provider
Posts: 34
Liked: 2 times
Joined: Feb 27, 2020 6:38 am
Contact:

Re: Get-VBRBackup changes v11 to v12 and Offloading S3

Post by Refruit »

Hi Oleg,

thank you for the quick reply! I'm gonna try that out.
Thank you very much!

Best regards,
Refruit
squebel
Service Provider
Posts: 131
Liked: 12 times
Joined: Sep 27, 2019 5:06 pm
Contact:

Re: Get-VBRBackup changes v11 to v12 and Offloading S3

Post by squebel »

Can confirm this works in v12 and if you have a true per-vm backup chain. Thanks for the info, Oleg.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests