PowerShell script exchange
Post Reply
JeroenConfirmed
Lurker
Posts: 2
Liked: never
Joined: Feb 25, 2025 8:10 am
Contact:

Get running Offload jobs for X number of days and terminate them

Post by JeroenConfirmed »

Some time ago we had issues with Cloudconnect Offloading jobs which kept piling up. We had to manually kill them trough the task manager, but there is no indication which job is what.

I was thinking of putting a script together to automate this, should this come back in the future.
I have found some usable snippets of code from following forum posts:
powershell-f26/how-to-manage-jobs-in-th ... 86341.html
powershell-f26/sobr-azure-offload-statu ... 65880.html

I currently have this incomplete non working code:

Code: Select all

#Connect to VBR
Connect-VBRServer

#Define SOBR offload job  = Archivebackup
$sobrOffload = [Veeam.Backup.Model.EDbJobType]::ArchiveBackup
#Get running SOBR offload jobs
$runningSessionsArchiveBackup = [Veeam.Backup.Core.CBaseSession]::GetRunning($sobrOffload)
#write $runningSessionsArchiveBackup

$runningSessionsArchiveBackupOlderThan7days= [Veeam.Backup.Core.CBackupSession]::GetByTypeAndTimeInterval($runningSessionsArchiveBackup,(Get-Date).adddays(-7), (Get-Date).adddays(1)) 
write $runningSessionsArchiveBackupOlderThan7days
It seems you cannot mix EDBJobType and GetByTypeAndTimeInterval according to the error:
Cannot convert argument "jobType", with value: "Veeam.Backup.Model.CBaseSessionInfo[]", for "GetByTypeAndTimeInterval" to type "Veeam.Backup.Model.EDbJobT
ype": "Cannot convert the "Veeam.Backup.Model.CBaseSessionInfo" value of type "Veeam.Backup.Model.CBaseSessionInfo" to type "Veeam.Backup.Model.EDbJobType
"."


The goal here is to get the running SOBR Offload jobs, for example 7 days, and terminate the ones older than a given time.

If anyone can aid me in this, I would be very grateful
david.domask
Veeam Software
Posts: 2629
Liked: 611 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get running Offload jobs for X number of days and terminate them

Post by david.domask »

Hi JeroenConfirmed, welcome to the forums.

The above code is using unsupported methods, so not sure it's worth diving too deeply into the code -- the issue looks to be that GetByTypeAndTimeInterval() expects a job type but you pass a CBaseSession object. Should work to just replace $runningSessionsArchiveBackup with $sobrOffload when you populate $runningSessionsArchiveBackupOlderThan7days.

However, for a supported way of doing this, use Get-VBRSession with the -Type Parameter -- check the cmdlet documentation with Get-Help to see the valid values for Type, but you want the Archive* job types. ArchiveBackup is move to Capacity Tier, ArchiveCopy for copy to Capacity Tier, etc.
David Domask | Product Management: Principal Analyst
JeroenConfirmed
Lurker
Posts: 2
Liked: never
Joined: Feb 25, 2025 8:10 am
Contact:

Re: Get running Offload jobs for X number of days and terminate them

Post by JeroenConfirmed »

Hello David,

I shall have a look at the official VBR Cmdlets and get back to this post when I have something. Thank you for the guidance.

Jeroen
Post Reply

Who is online

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