RESTful knowledge exchange
Post Reply
yamakawa
Novice
Posts: 8
Liked: never
Joined: Oct 02, 2020 7:11 am
Contact:

How can I get snapshot-status with RESTful API?

Post by yamakawa »

Hi.

I use the RESTful API to launch and check the status of my backup jobs.

I'm using State, Result and Progress to check the status of the backup job, but is it possible to get the status of the snapshot completion instead of the status of the entire backup job?

Code: Select all

#!/user/bin/python3
import requests
import json

# session_id, job_name are already set using API

headers={
  'X-RestSvcSessionId': session_id,
  'Accept': 'application/json'
}

params={
  'type': 'BackupJobSession',
  'format': 'Entities',
  'sortDesc': 'Name',
  'filter': 'jobname="{0}"'.format(job_name),
  'pageSize': 1
}

url='https://<ip>:9398/api/query'

response = requests.get(url, headers=headers, params=params, verify=False)
data = json.loads(response.text)
If there is a person who knows, it would be appreciated if you could answer.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How can I get snapshot-status with RESTful API?

Post by oleg.feoktistov »

Hi and Welcome to our Community Forums!

Sure, you just need to query backup task sessions with VmDisplayName filter:

Code: Select all

params={
  'type': 'BackupTaskSession',
  'format': 'Entities',
  'sortDesc': 'Name',
  'filter': 'VmDisplayName==%s' % vm_name,
  'pageSize': 1
}
You'll also find a relation to a particular backup session in the output object. Just in case you want to filter it further.

Thanks,
Oleg
yamakawa
Novice
Posts: 8
Liked: never
Joined: Oct 02, 2020 7:11 am
Contact:

Re: How can I get snapshot-status with RESTful API?

Post by yamakawa »

Dear Oleg

Thanks for the reply.

I was not able to consider backupSessions and backupTaskSessions separately.
I have found it appropriate to use backupTaskSessions in this case.
I actually used backupTaskSessions to check the backup status and the State transitioned as follows.
Pending→InProgress→Completed
Is the snapshot taken when State is inProgress? Or is it in the Completed stage?

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

Re: How can I get snapshot-status with RESTful API?

Post by oleg.feoktistov »

Hi @yamakawa,

Sorry for the confusion. I thought by a snapshot you meant a backup taken on our side.
Snapshot on VMware side is taken during InProgress state of a task session.
Though currently it is not possible to query it directly neither with EM REST, nor with VMware REST API.
It gets exposed only through PowerCLI:

Code: Select all

$vm = Get-VM -Name 'VmDisplayName'
$snapshotsEvents = Get-ViEvent -Entity $vm | where {$_.FullFormattedMessage -eq 'Task: Create virtual machine snapshot'}
foreach ($event in $snapshotEvents) {
     $event.Info
} 
Thanks,
Oleg
yamakawa
Novice
Posts: 8
Liked: never
Joined: Oct 02, 2020 7:11 am
Contact:

Re: How can I get snapshot-status with RESTful API?

Post by yamakawa »

Hi @oleg

Currently, the server I am trying to get a backup of using the RESTful API is RHEL 7.7 and does not have powershell installed.
I'll hold off on changing my environment to install powershell and VMware's powerCLI, as it's not a decision I can make lightly.
Just finding out that I can't use the RESTful API to get status was a boon.

Thank you for the answers above.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How can I get snapshot-status with RESTful API?

Post by oleg.feoktistov »

@yamakawa, by the way PowerShell Core is compatible with RHEL 7. So, you can download and install it from here.
Then just setup PowerCLI as you would do that on Windows:

Code: Select all

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Find-Module "VMware.PowerCLI" | Install-Module -Scope CurrentUser
And you are good to go.

Just curious - why would you need a status of vmware snapshot creation session rather than backup task session on our side when querying EM REST?

Thanks!
Oleg
yamakawa
Novice
Posts: 8
Liked: never
Joined: Oct 02, 2020 7:11 am
Contact:

Re: How can I get snapshot-status with RESTful API?

Post by yamakawa »

Dear @oleg

The reason I want to take a snapshot is that my system takes daily backups of areas that change daily, but there aren't enough hours in the day available for backups.
This is because there is a desire to start subsequent processing when the snapshot acquisition is complete, as waiting for subsequent processing to complete the backup job can cause delays.
When we were considering implementing VeeamAgent in the past, we heard that it could recognize the stage at which a snapshot was completed, so we wondered if we could do the same thing with the API.
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: How can I get snapshot-status with RESTful API?

Post by oleg.feoktistov »

Yes, VBR can query snapshot creation session on its backend and use this info to launch another stage of a task session.
It's just that this method is not available in our public API. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest