Create an Instance Snapshot

post

/snapshot/

Creates a snapshot request, which in turn creates a machine image to preserve all the changes made in the instance since launch.

There can be only one snapshot request in the active or queued state for an instance at any given time. After the request state changes to error or complete, you can issue another snapshot request for that instance.

This command returns a snapshot request identifier, which you can use to check the progress of the asynchronous snapshot request by sending a GET request with the snapshot request identifier. When the state of the request changes to complete, you can send the GET /machineimage/{name} request to verify that the machine image is created correctly.

If you use the "delay": "shutdown" option, the snapshot remains in the active state, until you shutdown the instance by deleting it. When the delete instance request (DELETE /instance/{name}) is executed, a snapshot of the instance is taken and a machine image is created, the state of the snapshot changes to complete, and then the instance is stopped and deleted.

Add this new machine image to an image list, and then use it to create a new instance.

Prerequisite: Ensure that you have selected a replication policy for your Oracle Cloud Infrastructure Object Storage Classic instance. See Selecting a Replication Policy for Your Service Instance in Using Oracle Cloud Infrastructure Object Storage Classic.

Required Role: To complete this task, you must have the Compute_Operations role. If this role isn't assigned to you or you're not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud My Services. See Modifying User Roles in Managing and Monitoring Oracle Cloud.

Request

Supported Media Types
Header Parameters
Body ()
The request body contains details of the instance snapshot that you want to create.
Root Schema : Snapshot-post-request
Type: object
The request body contains details of the instance snapshot that you want to create.
Show Source
  • Two-part name of the account (/Compute-identity_domain/user/object) that contains the credentials and access details of Oracle Cloud Infrastructure Object Storage Classic. The machine image file is uploaded to the Oracle Cloud Infrastructure Object Storage Classic account that you specify.
  • Use this option when you want to take preserve the custom changes you have made to an instance before deleting the instance. The only permitted value is shutdown. Snapshot of the instance is not taken immediately. It creates a machine image which preserves the changes you have made to the instance, and then the instance is deleted.

    Note: This option has no effect if you shutdown the instance from inside it. Any pending snapshot request on that instance goes into error state. You must delete the instance (DELETE /instance/{name}).

  • Multipart name of the instance that you want to clone.
  • Specify the three-part name (/Compute-identity_domain/user/object) of the machine image created by the snapshot request.

    Object names can contain only alphanumeric characters, hyphens, underscores, and periods. Object names are case-sensitive.

    If you don't specify a name for this object, then the name is generated automatically.

Response

Supported Media Types

201 Response

Created. See Status Codes for information about other possible HTTP status codes.
Headers
Body ()
Root Schema : Snapshot-response
Type: object
Show Source

Examples

cURL Command

The following example shows how to create an instance snapshot by submitting a POST request on the REST resource using cURL. For more information about cURL, see Use cURL.

Enter the command on a single line. Line breaks are used in this example for readability.

curl -i -X POST
     -H "Cookie: $COMPUTE_COOKIE"
     -H "Content-Type: application/oracle-compute-v3+json"
     -H "Accept: application/oracle-compute-v3+json"
     -d "@requestbody.json"
        https://api-z999.compute.us0.oraclecloud.com/snapshot/
  • COMPUTE_COOKIE is the name of the variable in which you stored the authentication cookie earlier. For information about retrieving the authentication cookie and storing it in a variable, see Authentication.

  • api-z999.compute.us0.oraclecloud.com is an example REST endpoint URL. Change this value to the REST endpoint URL of your Compute Classic site. For information about finding out REST endpoint URL for your site, see Send Requests.

Example of Request Body

The following shows an example of the request body content in the requestbody.json file to create a snapshot of the /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d instance and create a machine image with the specified name, /Compute-acme/jack.jones@example.com/snapshot1.

{
"account": "/Compute-acme/cloud_storage",
"delay": "", 
"instance": "/Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d", 
"machineimage": "/Compute-acme/jack.jones@example.com/snapshot1"
}

Example of Response Body

The following example shows the response body in JSON format. This HTTP request returns a snapshot request identifier, which you can use to check the progress of the asynchronous snapshot request by sending a GET request with the snapshot request identifier. When the state of the request changes to complete, you can send the GET /machineimage/{name} request to verify that the machine image is created correctly.

{
"instance_id": "a6fbb572-a584-486a-9314-56a24499028d",
"account": "/Compute-acme/cloud_storage", 
"platform": "linux", 
"name": "/Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/4dbb2b4c-d315-47ba-b938-696f74826bec", 
"client_owned": true, 
"sizes": {}, 
"creation_time": "2015-08-20T06:54:58Z", 
"uri": "https://api-z999.compute.us0.oraclecloud.com/snapshot/Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/4dbb2b4c-d315-47ba-b938-696f74826bec", 
"delay": "", 
"instance": "/Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d", 
"machineimage": "/Compute-acme/jack.jones@example.com/snapshot1", 
"state": "active", 
"user": "/Compute-acme/jack.jones@example.com", 
"file": "hdfs:///bimage/a6fbb572-a584-486a-9314-56a24499028d-4dbb2b4c-d315-47ba-b938-696f74826bec-snapshot.tar.gz", 
"request_id": "4dbb2b4c-d315-47ba-b938-696f74826bec", 
"error_reason": "", 
"image_format": "raw"
}