Share via


How to Create a Virtual Machine 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 to the way it was when the checkpoint was created.

To create a checkpoint, you only must reference the GUID of the virtual machine. The users that create the checkpoint must have the checkpoint permission in their user role. For more information, seeHow to Add a Permission to a User Role. A checkpoint is created by using the VMCheckPoints OData collection.

To create a checkpoint by using the .NET Framework

  1. Connect to the Service Provider FoundationVMM service.

  2. Obtain the ID of the SpfVMM.VirtualMachine for which you want to create a checkpoint.

  3. Create a new instance of the SpfVMM.VMCheckPoint class.

  4. Set the VMId property to the ID of the virtual machine.

  5. Set the StampId property to the stamp where the checkpoint is to reside.

  6. Set the Name and Description properties to the display name and describe why the checkpoint has been created.

  7. Call the AddToVMCheckPoints method on the VMM service object reference and pass in the checkpoint reference.

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

To create a checkpoint by using HTTP

  1. Create a new HTTP POST operation.

  2. Set the URL to the VMCheckPoints collection: https://server:30006/subscription-id/services/systemcenter/vmm/VMCheckPoints.

  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. The entity should have the following properties set:

    1. Set the VMId property to the ID of the virtual machine for which you want to create a checkpoint.

    2. Set the StampId property to the stamp where the checkpoint is to reside.

    3. Set the Name and Description properties to the display name and describe why the checkpoint has been created.

  5. Submit the HTTP request.

Example

The following code example shows how to create a virtual machine checkpoint. For more information, seeProgramming in Visual Studio with Service Provider Foundation Services.

SpfVMM.VMM vmmService = new SpfVMM.VMM(new Uri("https://wapserver:30005/97FD50F3-1DC0-41B6-A7C0-2B4FF4C3F7E3/services/systemcenter/vmm/"));  
vmmService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;  
  
var virtualMachine = vmmService.VirtualMachines.Where(vm => vm.ID == new Guid("3499b02c-8dc9-4c0d-aa83-097a1340cbda")).FirstOrDefault();  
  
if (virtualMachine != null)  
{  
    var checkpoint = new SpfVMM.VMCheckPoint();  
    checkpoint.VMId = virtualMachine.ID;  
    checkpoint.Name = "Testing Checkpoint #1";  
    checkpoint.StampId = virtualMachine.StampId;  
    checkpoint.Description = String.Format("This is a snapshot of the VM taken at {0}", DateTime.Now);  
  
    vmmService.AddToVMCheckPoints(checkpoint);  
    vmmService.SaveChanges();  
}  
  

Example

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

POST https://wapserver:30005/97FD50F3-1DC0-41B6-A7C0-2B4FF4C3F7E3/services/systemcenter/vmm/VMCheckPoints 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: spfn-457:8090  
Content-Length: 463  
Expect: 100-continue  
  
{  
    "odata.type": "VMM.VMCheckPoint",  
    "Accessibility": null,  
    "AddedTime": null,  
    "CheckpointID": null,  
    "Confirm": null,  
    "Description": "This is a snapshot of the VM taken at 8/19/2013 3:02:33 PM",  
    "Enabled": null, "ID": "00000000-0000-0000-0000-000000000000",  
    "ModifiedTime": null,  
    "Name": "Testing Checkpoint #1",  
    "ParentCheckpointID": null,  
    "RunAsynchronously": null,  
    "StampId": "ba4146fa-fb41-4f59-a193-ad00c52a138c",  
    "VMCheckPointAction": null,  
    "VMId": "3499b02c-8dc9-4c0d-aa83-097a1340cbda"  
}  
  

Example

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

HTTP/1.1 201 Created  
Cache-Control: no-cache  
Content-Length: 651  
Content-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8  
Location: https://wapserver:30005/97FD50F3-1DC0-41B6-A7C0-2B4FF4C3F7E3/services/systemcenter/vmm/VMCheckPoints(ID=guid'a11cc636-5521-4f88-92b2-cad392911fe0',StampId=guid'ba4146fa-fb41-4f59-a193-ad00c52a138c')  
Server: Microsoft-IIS/8.5  
x-ms-request-id: e381ad2b-2375-45e4-a45f-64a1447a4ef6  
X-Content-Type-Options: nosniff  
request-id: eda9bde6-834a-0001-3608-abed4a83ce01  
DataServiceVersion: 3.0;  
X-AspNet-Version: 4.0.30319  
Persistent-Auth: true  
X-Powered-By: ASP.NET  
Date: Mon, 19 Aug 2013 22:02:36 GMT  
  
{  
    "odata.metadata": "https://wapserver:30005/97FD50F3-1DC0-41B6-A7C0-2B4FF4C3F7E3/services/systemcenter/vmm/$metadata#VMCheckPoints/@Element",  
    "Accessibility": "Public",  
    "AddedTime": "2013-08-19T15:02:36.591591-07:00",  
    "CheckpointID": null,  
    "Confirm": null,  
    "Description": "This is a snapshot of the VM taken at 8/19/2013 3:02:33 PM",  
    "Enabled": true,  
    "ID": "a11cc636-5521-4f88-92b2-cad392911fe0",  
    "ModifiedTime": "2013-08-19T15:02:36.8185926-07:00",  
    "Name": "Testing Checkpoint #1",  
    "ParentCheckpointID": null,  
    "RunAsynchronously": null,  
    "StampId": "ba4146fa-fb41-4f59-a193-ad00c52a138c",  
    "VMCheckPointAction": null,  
    "VMId": "3499b02c-8dc9-4c0d-aa83-097a1340cbda"  
}  
  

See Also

Checkpoints
How to Delete a Virtual Machine Checkpoint
How to Restore a VM From a Checkpoint