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.