Solved

VBR powershell command to fetch agent based backup


Userlevel 2
  • Not a newbie anymore
  • 9 comments

Hi All,

 

I need a Veeam powershell command to fetch agent based backup.

 

I am using below command to fetch last night backup status but it doesn’t include agent based backup.

 

Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}

 

Do you know single command to fetch all types of backup or different command for agent based backup?

 

Thanks in advance

icon

Best answer by JMeixner 16 May 2022, 20:24

View original

12 comments

Userlevel 7
Badge +17

Try using $.JobType -eq “EpAgentBackup”

But this deprecated as far as I know, have a look at the Get-VBRComputerBackupJob cmdlet.

Userlevel 7
Badge +7

Hi @Surya 

this for Agent - Returns backup jobs run by Veeam Agent operating in a standalone mode.

Get-VBREPJob - Veeam Backup PowerShell Reference

 

This for managed Agent:

Get-VBRComputerBackupJob - Veeam Backup PowerShell Reference

 

Userlevel 2

Try using $.JobType -eq “EpAgentBackup”

But this deprecated as far as I know, have a look at the Get-VBRComputerBackupJob cmdlet.

Thanks

Get-VBRComputerBackupJob is working. Can I segregate the each client backup statistics?
 

i need details "Name","Jobname","Status","StartTime","EndTime","TransferedSizeinMB"

Userlevel 2

Hi @Surya 

this for Agent - Returns backup jobs run by Veeam Agent operating in a standalone mode.

Get-VBREPJob - Veeam Backup PowerShell Reference

 

This for managed Agent:

Get-VBRComputerBackupJob - Veeam Backup PowerShell Reference

 

Thanks

Get-VBRComputerBackupJob is working. Can I fetch the each client backup statistics?
 

i need details "Name","Jobname","Status","StartTime","EndTime","TransferedSizeinMB"

Userlevel 7
Badge +17

Try using $.JobType -eq “EpAgentBackup”

But this deprecated as far as I know, have a look at the Get-VBRComputerBackupJob cmdlet.

Thanks

Get-VBRComputerBackupJob is working. Can I segregate the each client backup statistics?
 

i need details "Name","Jobname","Status","StartTime","EndTime","TransferedSizeinMB"

You can do this with
Get-VBRComputerBackupJoB | select Name,Jobname,Status,StartTime,EndTime,TransferedSizeinMB

Userlevel 2

Try using $.JobType -eq “EpAgentBackup”

But this deprecated as far as I know, have a look at the Get-VBRComputerBackupJob cmdlet.

Thanks

Get-VBRComputerBackupJob is working. Can I segregate the each client backup statistics?
 

i need details "Name","Jobname","Status","StartTime","EndTime","TransferedSizeinMB"

You can do this with
Get-VBRComputerBackupJoB | select Name,Jobname,Status,StartTime,EndTime,TransferedSizeinMB

Thanks for your reply

 

it doesnt get me each client backup statistics ( null value is printed on Status, StartTime,EndTime,Size).

I have used below queries for VM backup status.

# 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)}}}
 

 

Can i get similar one for agent based backup?

Userlevel 7
Badge +17

Yes, you can.

Try get-vbrcomputerjobsession

https://helpcenter.veeam.com/docs/backup/powershell/get-vbrcomputerbackupjobsession.html?ver=110

 

Then you get something like this:

CreationTime : 18.02.2022 04:30:13

EndTime      : 18.02.2022 04:40:59

JobId        : c1de222e-382d-487d-b42e-8fc991bd8d11

Result       : Success

State        : Stopped

Id           : 32d9bec6-e679-4bc6-b9e2-b06dc6961700

CreationTime : 17.02.2022 14:05:52

EndTime      : 17.02.2022 14:16:59

JobId        : c1de222e-382d-487d-b42e-8fc991bd8d11

Result       : Success

State        : Stopped

Id           : 8f3fe24e-50cb-4986-a6e7-b30e61af258a

 

It is not completely what you want, but it is a beginning….

Userlevel 2

 

Thanks for all your responses.

 

Get-VBRComputerBackupJoB is only fetching job status. I haven’t each and every client in that job.

 

Can you please help me to fetch each client’s backups status?

Userlevel 7
Badge +17

Hi,
please try this script:

$job = Get-VBRComputerBackupJob -Name 'Agent Backup Job'
$sessions = Get-VBRComputerBackupJobSession -Name "$($job.Name)?*"
foreach ($session in $sessions) {
Get-VBRTaskSession -Session $session
}

This gets you the name of the backed up system and the status.  You can get more information from each session, please experiment a little bit with this to get the specific information you need. 😃

 

Userlevel 2

 

I have developed below script by God’s grace and it worked for me

 

 

$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)}}
}
}

 

 

Thanks all for your support

Can you please help me to fetch each client’s backups failed status?

Userlevel 2

 

Below script will fetch you the failed clients in last 24 hours 

 

(it will work for VM not for plugin & agent based. If you need that also, let me know)

 

$vbrsessions = Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}

$client = foreach ($session in $vbrsessions) {$session.gettasksessions()|Where-Object {$_.Status -eq "Failed"}| Select Name, Jobname, Status, @{n='StartTime';e={$_.Progress.StartTimeLocal}}, @{n='EndTime';e={$_.Progress.StopTimeLocal}},@{n='TransferedSizeinMB';e={[math]::Round(($_.Progress.TransferedSize/1048576),2)}}}

Comment