RESTful knowledge exchange
Post Reply
arif
Novice
Posts: 8
Liked: 2 times
Joined: Mar 25, 2020 2:31 pm
Full Name: Arif Cetiner
Contact:

VM Entire Restore API Problem

Post by arif »

Hello,

We want to perform a restore operation via the Veeam REST API.

We're using the APIs at https://localhost:9398/api/ at version 1.7.

We're experiencing an issue during the Entire VM Restore process.

The endpoint we're using is: https://helpcenter.veeam.com/docs/backu ... ml?ver=120

Here, the restoration process completes, but it overwrites the existing VM and detects the PowerOnAfter Restore value.

However, our goal is to preserve the original VM and create the restored VM with a new name.

Upon inspecting the relevant endpoint, we noticed that QuickRollback should be set to false, and KeepOriginalVM should be true.

We've also used the VmNewName parameter.

In the request body, we've implemented the JSON structure provided on the website:

json

Code: Select all

{
  "VmRestoreSpec": {
    "PowerOnAfterRestore": false,
    "HierarchyRootUid": "urn:veeam:HierarchyRoot:1ed39e5b-06e1-4fbb-a106-52537b5e059e",
    "QuickRollback": false,
    "VmRestoreParameters": {
      "VmRestorePointUid": "urn:veeam:VmRestorePoint:af9396fb-99e6-4e94-a82a-914cc5a3f810",
      "VmNewName": "VM-restored",
      "DatastoreRef": "urn:vCloud:Datastore:1ed39e5b-06e1-4fbb-a106-52537b5e059e.urn:vcloud:datastore:9cfafa2e-e57b-4bc5-9690-933947c62b80",
      "OrgVdcStorageProfileRef": "urn:vCloud:OrgVdcStorageProfile:1ed39e5b-06e1-4fbb-a106-52537b5e059e.urn:vcloud:vdcstorageprofile:7e7ffe3a-33fa-4f9e-805b-c08b1a3645bf",
      "LinkedCloneVmTemplateRef": ""
    }
  }
}
We couldn't determine what value to send for "OrgVdcStorageProfileRef," so we excluded it from the request.

Regardless of what we do, after the restore operation completes, it only overwrites the existing VM.

What could we possibly be doing wrong here?
oleg.feoktistov
Veeam Software
Posts: 1977
Liked: 655 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: VM Entire Restore API Problem

Post by oleg.feoktistov »

Hi,

Looks like a bug to me. Let me reproduce it with QA and follow up on the thread. Meanwhile, would using the same kind of call but for VBR REST API be applicable in your case?

Thanks,
Oleg
arif
Novice
Posts: 8
Liked: 2 times
Joined: Mar 25, 2020 2:31 pm
Full Name: Arif Cetiner
Contact:

Re: VM Entire Restore API Problem

Post by arif »

Hello,

I've also made some attempts via Swagger. It overwrites the data on the current VM. I want it to preserve the existing data and write something new.

I'm sending the request through PHP Laravel as follows:

php

Code: Select all

public function restore(string $restorePointId): Collection|\Exception
{
    $response = Http::withHeaders([
        'X-RestSvcSessionId' => $this->sessionId,  // This data is assigned within the construct
        'Accept' => 'application/json',
    ])
        ->withOptions(['verify' => false])
        ->post($this->baseUrl."/vmRestorePoints/{$restorePointId}?action=restore",
        [
            'VmRestoreSpec' => [
                'PowerOnAfterRestore' => false,
                'QuickRollback' => false,
                'KeepOriginalVM' => true,
            ],
        ]);

    $results = $response->json();

    if ($response->successful()) {
        return collect($results);
    } else {
        throw new \Exception("An error occurred while making a request to the Veeam Rest API /vmRestorePoints/{restorePointId}?action=restore endpoint.\n"
            ."Error code: {$results['StatusCode']}\n"
            ."Error message: {$results['Message']}", $response->status());
    }
}
The API page provides the following example:

Code: Select all

Request:
POST https://localhost:9398/api/vmRestorePoints/b32c22c4-79af-4486-b2e2-1a3897db5c61?action=restore

Request Headers:
X-RestSvcSessionId NDRjZmJkYmUtNWE5NS00MTU2LTg4NjctOTFmMDY5YjdjMmNjContent-Type application/xml

Request Body:

<?xml version="1.0" encoding="utf-8"?><RestoreSpec xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  <VmRestoreSpec>    <PowerOnAfterRestore>false</PowerOnAfterRestore>    <QuickRollback>false</QuickRollback>    <KeepOriginalVM>true</KeepOriginalVM>  </VmRestoreSpec></RestoreSpec>
Response:
202 Accepted

Response Body:
<Task xmlns="http://www.veeam.com/ent/v1.0" Type="Task" Href="https://localhost:9398/api/tasks/task-1"> <Links> <Link Rel="Delete" Type="Task" Href="https://localhost:9398/api/tasks/task-1" /> </Links> <TaskId>task-1</TaskId> <State>Running</State> <Operation>StartVMRestore</Operation></Task>
I think it's ignoring my KeepOriginalVM parameter. Additionally, I noticed a parameter called VmNewName on the page. I added it to the request but it didn't change the result.

The API I'm using: https://helpcenter.veeam.com/docs/backu ... ml?ver=120

I also sent a request to the API endpoint you suggested as follows:

php

Code: Select all

public function startEntireVmRestore(string $restorePointId): Collection|\Exception
{
    $response = Http::withHeaders([
       'x-api-version' => '1.1-rev0'
        'Authorization' => 'Bearer '.$this->token,
        'Accept' => 'application/json',
    ])
        ->withOptions(['verify' => false])
        ->post($this->baseUrl.'/v1/restore/vmRestore/vmware', [
                'objectRestorePointId' => $restorePointId,
                'type' => 'Customized',
                'restoreProxies' => [
                    'autoSelection' => true,
                    'proxyIds' => [
                        '61231239-2225-4ca2-b1a2-asdasdasde60ef8',   // example values
                    ],
                ],
                'secureRestore' => [
                    'enableAntivirusScan' => true,
                    'virusDetectionAction' => 'DisableNetwork',
                    'enableEntireVolumeScan' => true,
                ],
                'powerUp' => true,
                'reason' => 'Your reason here',
                'quickRollback' => false,
                'destinationHost' => [
                    'hostName' => 'XXX.XXX.XXX.XXX',
                    'name' => 'XXX.XXX.XXX.XXX',
                    'type' => 'Host',
                    'objectId' => 'host-63',
                ],
                'resourcePool' => [
                    'hostName' => 'XXX.XXX.XXX.XXX',
                    'name' => 'Pool',
                    'type' => 'ResourcePool',
                    'objectId' => 'resgroup-137',
                ],
//                'datastore' => [
//                    'datastore' => [
//                        'hostName' => 'XXX.XXX.XXX.XXX',
//                        'name' => 'datastore',
//                        'type' => 'Datastore',
//                        'objectId' => '',
//                    ],
//                    'diskType' => 'Source',
//                ],
                'folder' => [
                    'vmName' => 'Test-Restored',  // I also tried this to give a new VM name
                    'folder' => [
                        'hostName' => 'XXX.XXX.XXX.XXX',
                        'name' => 'host',
                        'type' => 'Folder',
                        'objectId' => 'group-h4',
                    ],
                    'restoreVmTags' => false,
                ],
                'network' => [
                    'network' => [
                        'hostName' => 'XXX.XXX.XXX.XXX',
                        'name' => 'VM Network',
                        'type' => 'Network',
                        'objectId' => '',
                    ],
                    'disconnected' => false,
                ],
            ]);

    $results = collect($response->json());

    if ($response->successful()) {
        return $results;
    } else {
        throw new \Exception("An error occurred while making a request to the VeeamApi(Swagger) /v1/restore/vmRestore/vmware endpoint!\n"
            .'Error message: '.$results['message'], $response->status());
    }
}
I'm obtaining values like resourcePool, folder from the following endpoint: https://helpcenter.veeam.com/docs/backu ... HostObject

I had to comment out the datastore part since the values didn't come through. It didn't throw an error, but the same thing happened. It overwrites the backup.
oleg.feoktistov
Veeam Software
Posts: 1977
Liked: 655 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: VM Entire Restore API Problem

Post by oleg.feoktistov »

Hi Arif,

Thanks for letting me know that for VBR REST it also doesn't work. I will need to check it with our QA team.
As for the initial call via EM REST - looks like it's a known issue that has been fixed in a cumulative patch for v12.
Here is the article with patches/iso links. You'll need v12 P20230718.
It also works in our new 12.1 version that's coming any day now.

Best regards,
Oleg
arif
Novice
Posts: 8
Liked: 2 times
Joined: Mar 25, 2020 2:31 pm
Full Name: Arif Cetiner
Contact:

Re: VM Entire Restore API Problem

Post by arif » 2 people like this post

Hello Oleg,

First of all, thank you very much for your interest.

I managed the restore operation with the VBR REST API successfully.

The issue was with the expected request body:

Code: Select all

{
  "folder": {
    "vmName": "string",
    "folder": {
      "hostName": "string",
      "name": "string",
      "type": "Unknown",
      "objectId": "string"
    },
    "restoreVmTags": true
  }
}

It turned out that I was sending the wrong value for the objectId under the folder parameter. Once I sent the correct value, the operation completed successfully.

However, there might be a problem with the other API I mentioned earlier at https://helpcenter.veeam.com/docs/backu ... ml?ver=120
because I couldn't manage to preserve the existing VM and restore it with a new name.

I'm continuing with my journey using the VBR REST API. : )

Thanks again.
oleg.feoktistov
Veeam Software
Posts: 1977
Liked: 655 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: VM Entire Restore API Problem

Post by oleg.feoktistov »

Glad you got it working with VBR REST API! Cheers!
Post Reply

Who is online

Users browsing this forum: patrikcze and 46 guests