PowerShell script exchange
Post Reply
Suryanarayanan
Influencer
Posts: 14
Liked: 3 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:

Command to fetch agent based backups of last 24 hours

Post by Suryanarayanan »

HI Team,


We are fetching Virtual machines backup status from Backup server with the below script.

Is there any possibility to fetch agent based backups (ex: Linux & Windows physical servers, RMAN)

Code: Select all

# Fetch each backup job sessions from VBR for the last 24 hours
$vbrsessions = Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}

# Fetch each client session details from each backup job
$client = foreach ($session in $vbrsessions) {$session.gettasksessions()| Select Name, Jobname, Status, @{n='StartTime';e={$_.Progress.StartTimeLocal}}, @{n='EndTime';e={$_.Progress.StopTimeLocal}},@{n='TransferedSizeinMB';e={[math]::Round(($_.Progress.TransferedSize/1048576),2)}}}
$setarray = @("Name","JobName", "Status", "StartTime", "EndTime", "TransferedSizeinMB" )

# Export a client summary to csv with coloumns Server, Job, Status, StartTime,EndTime, TransferedSizeinMB
$client | Select-Object -Property $setarray | Export-CSV -Encoding "UTF8" -NoTypeInformation c:\backupstatus.csv
Regards,
Suryanarayanan
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Command to fetch agent based backups of last 24 hours

Post by soncscy » 1 person likes this post

Hi Suryanarayanan,

Please use the forum search and check the user guide. For linux and windows servers, use Get-VBRComputerBackupSession.

RMAN has some challenges and I'm not sure that getting the Sessions is fully supported: https://helpcenter.veeam.com/docs/backu ... ml?ver=110

But there are unsupported workarounds on the forums if you search.
Suryanarayanan
Influencer
Posts: 14
Liked: 3 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:

Re: Command to fetch agent based backups of last 24 hours

Post by Suryanarayanan »

Get-VBRComputerBackupSession is deprecated . I have tried with Get-VBRComputerBackupJob but cant get each client's backup status.

Can anybody help to get the agent backup details?

details such as "Name","Jobname","Status","StartTime","EndTime","TransferedSizeinMB"
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Command to fetch agent based backups of last 24 hours

Post by david.domask »

I think harvey meant Get-ComputerBackupJobSession:

https://helpcenter.veeam.com/docs/backu ... ml?ver=110

Which is not deprecated.

As for the information, as Harvey noted, a quick search reveals this thread: post400656.html#p400656

Agent data is a bit more "controlled", so you will need to craft some code on your own to make this work in full.
David Domask | Product Management: Principal Analyst
Suryanarayanan
Influencer
Posts: 14
Liked: 3 times
Joined: Jul 09, 2021 12:42 pm
Full Name: Suryanarayanan
Location: Bangalore India
Contact:

Re: Command to fetch agent based backups of last 24 hours

Post by Suryanarayanan » 1 person likes this post

By God's grace, below script worked for me. Thanks for all your support

Code: Select all

$job =Get-VBRComputerBackupJob
foreach ($sessions in $job) 
{ 
$jname = Get-VBRComputerBackupJobSession -Name "$($sessions.Name)?*"
$jname1=$jname| where-object {$_.EndTime -ge (Get-Date).addhours(-24)}
foreach ($session in $jname1) 
{
Get-VBRTaskSession -Session $session| Select-Object -Property Name,@{n='Jobname';e= {$($sessions.Name)}},status,@{n='StartTime';e={$_.Progress.StartTimeLocal}}, @{n='EndTime';e={$_.Progress.StopTimeLocal}},@{n='TransferedSizeinMB';e={[math]::Round(($_.Progress.TransferedSize/1048576),2)}}
}
}
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests