Solved

API for VMs Backups History

  • 6 July 2022
  • 3 replies
  • 427 views

Userlevel 3
Badge +11

Hello Community ,

I need to Pull out VMs( VSA snapshot backup)  backup history ( all available backup details like start time , end time , status) through an API . The Commvault GetVM API is only giving the status about recent backup .

Which API can be used to get information about all available backups for VMs ?

Regards,Mohit

icon

Best answer by AbdulWajid 11 July 2022, 07:04

View original

3 replies

Userlevel 7
Badge +23

There’s a few options to check out (and including the one you mentioned):

Get VM:

https://api.commvault.com/#c39d4219-26e0-4090-b6a0-103f8319330b

Get VM Jobs:

https://api.commvault.com/#c6135933-ef59-46fc-9392-9861875eeb47

Have you looked at the second one?

Also, not sure if you were looking on our API site, or just the main documentation.  The API site has a LOT more to look at!

Userlevel 3
Badge +11

@Mike Struening 

Thanks for the reply.

Get VM Jobs :

https://api.commvault.com/#c6135933-ef59-46fc-9392-9861875eeb47

This ones gives the start and end time of complete Job not for individual VMs which are present in that particular Job , subclient or vmgroup .

 

Is there any API where i can get information start time , end time , status for all available/protected backups for a particular VM ?

 

Regards,

Mohit

Badge +4

You have the option to use “GET VM Jobs” to get the JobID and then use “POST Job Details” to get the individual VM details. I use a PowerShell function that you can modify and use.

 

function Get-CVJobDetails {
param (
$jobId, $cvToken
)
Write-Verbose "Getting details for Job ID: $jobId"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type","application/json")
$headers.Add("Accept","application/json")
$headers.Add("Authtoken", $cvToken)
$body = "{
`n `"jobId`": $jobId
`n}"
$response = Invoke-RestMethod -Uri "http://$CommServ/webconsole/api/JobDetails" -Method POST -Headers $headers -Body $body
#Write-Verbose $response.job.jobDetail.clientStatusInfo.vmStatus[0]
$jobStatus = $response.job.jobDetail.clientStatusInfo.vmStatus.Status
if ($jobStatus -eq "0"){
$jobStatus = "Completed"
$percentComplete = 100
}
if ($jobStatus -eq "1"){
$jobStatus = "Failed"
}
if ($jobStatus -eq "2"){
$jobStatus = "In Progress"
$percentComplete = $response.job.jobDetail.progressInfo.percentComplete

}
if ($jobStatus -eq "3"){
$jobStatus = "Partial Success"
}
if ($jobStatus -eq "4"){
$jobStatus = "Waiting"
}
if ($jobStatus -eq "5"){
$jobStatus = "Kill Pending"
}
if ($jobStatus -eq "6"){
$jobStatus = "Killed"
}

$JobDetails = [PSCustomObject]@{
"VMName" = [STRING]$response.job.jobDetail.clientStatusInfo.vmStatus.VMName.toupper()
"JobId" = $jobId
"VirtualizationClient" = $response.job.jobdetail.generalInfo.subclient.clientName.toupper()
"SubClient" = [STRING]$response.job.jobdetail.generalInfo.subclient.displayName.toupper()
"Status" = $jobStatus
"PercentComplete" = [STRING]$percentComplete + " %"
"VMHost" = [STRING]$response.job.jobDetail.clientStatusInfo.vmStatus.Host.toupper()
"Proxy" = [STRING]$response.job.jobDetail.clientStatusInfo.vmStatus.Agent.toupper()
"MediaAgent" = [STRING]$response.job.jobDetail.clientStatusInfo.vmStatus.mediaAgentName.toupper()
"BackupStartTime" = Get-UnixDate $response.job.jobDetail.clientStatusInfo.vmStatus.BackupStartTime
"BackupEndTime" = Get-UnixDate $response.job.jobDetail.clientStatusInfo.vmStatus.BackupEndTime
"vmSize" = [STRING][Math]::Round((($response.job.jobDetail.clientStatusInfo.vmStatus.size)/1gb),2) + " GB"
"guestSize" = [STRING][Math]::Round((($response.job.jobDetail.clientStatusInfo.vmStatus.GuestSize)/1gb),2) + " GB"
"backupSize" = [STRING][Math]::Round((($response.job.jobDetail.clientStatusInfo.vmStatus.UsedSpace)/1gb),2) + " GB"
}
return $JobDetails
#return $response
}

 

Reply