Freigeben über


How to Restore a VM From a Checkpoint

 

Applies To: System Center 2016 - Service Provider Foundation, System Center Technical Preview

Virtual machine checkpoints provide a way to capture the state of a virtual machine. The checkpoint can then be used to restore the virtual machine back to the way it was when the checkpoint was created.

To restore a checkpoint state to a virtual machine, you update an existing Checkpoint object. Set the VMCheckPointAction property to Restore and submit the changed entity back to the server. You can use a MERGE or PUT HTTP operation for this process.

To restore a checkpoint to a virtual machine by using the .NET Framework

  1. Connect to the Service Provider FoundationVMM service.

  2. Obtain reference to the specific SpfVMM.VMCheckPoint to which you want to restore an associated virtual machine.

  3. Set the VMCheckPointAction property to Restore.

  4. Call the UpdateObject method on the VMM service object reference and pass in the checkpoint reference.

  5. Call the SaveChanges method on the VMM service object reference.

To restore a checkpoint to a virtual machine by using HTTP

  1. Create a new HTTP PUT or MERGE operation.

    Important

    If you supply only the key and changed properties, use a MERGE operation. The PUT operation is used when you want to replace all properties on the entity with new or default values. The MERGE operation updates the existing entity with the supplied properties. The PUT operation updates the existing entity with the supplied properties, but resets all missing properties back to their default values.

  2. Set the URL to the URI of a specific checkpoint: https://server:30006/subscription-id/services/systemcenter/vmm/VMCheckPoints(ID=guid'checkpoint-id',StampId=guid'stamp-id')

  3. Add the HTTP headers.

    Specifically, add the x-ms-principal-id header, which can be set to any value.

  4. Create the HTTP payload that contains the checkpoint entity with the VMCheckPointAction property set to Restore.

  5. Submit the HTTP request.

Example

The following code example shows how to get a specific checkpoint and how to restore it. For more information, seeProgramming in Visual Studio with Service Provider Foundation Services.

var checkpoint = vmmService.VMCheckPoints.Where(cp => cp.ID == new Guid("a11cc636-5521-4f88-92b2-cad392911fe0")).FirstOrDefault();  
  
if (checkpoint != null)  
{  
    checkpoint.VMCheckPointAction = "Restore";  
    vmmService.UpdateObject(checkpoint);  
    vmmService.SaveChanges();  
}  
  

Example

The following code example is an HTTP request that is sent to the server.

MERGE https://wapserver:30006/BA4146FA-FB41-41B6-A7C0-2B4FF4C3F7E3/services/systemcenter/vmm/VMCheckPoints(ID=guid'a11cc636-5521-4f88-92b2-cad392911fe0',StampId=guid'ba4146fa-fb41-4f59-a193-ad00c52a138c') HTTP/1.1  
DataServiceVersion: 3.0;NetFx  
MaxDataServiceVersion: 3.0;NetFx  
Accept: application/json;odata=minimalmetadata  
Accept-Charset: UTF-8  
DataServiceUrlConventions: KeyAsSegment  
User-Agent: Microsoft ADO.NET Data Services  
x-ms-principal-id: user@contoso.com  
Content-Type: application/json;odata=minimalmetadata  
Host: wapserver:30006  
Content-Length: 80  
Expect: 100-continue  
  
{  
    "VMCheckPointAction": "Restore",  
    "odata.type": "VMM.VMCheckPoint"  
}  
  

Example

The following code example shows the HTTP response from the server.

HTTP/1.1 204 No Content  
Cache-Control: no-cache  
Server: Microsoft-IIS/8.5  
x-ms-request-id: 6e0d9045-9d24-4ac1-93fc-a172e09af870  
X-Content-Type-Options: nosniff  
request-id: eda9bde6-834a-0000-2eda-aced4a83ce01  
DataServiceVersion: 1.0;  
X-AspNet-Version: 4.0.30319  
Persistent-Auth: true  
X-Powered-By: ASP.NET  
Date: Mon, 19 Aug 2013 22:13:09 GMT  
  

See Also

Checkpoints
How to Create a Virtual Machine Checkpoint
How to Delete a Virtual Machine Checkpoint