14 Instance Snapshot
When you run the delete instance
command, it shuts down the instance and removes it permanently from the system. This destroys all customizations you have made since the instance was launched. To preserve all the changes you have made in the instance since launch, create a snapshot of the modified instance. A machine image is created. Add this new machine image to an image list, and then use it to create a new instance.
Before running the CLI commands described in this section, make sure that you've installed the CLI client and set up the required environment variables as described in Preparing to Use the CLI.
Commands
snapshot add
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.
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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.
Syntax
opc compute snapshot add instance [--machineimage machineimage] [--delay=shutdown]
For help with the parameters and options of this command, run the command with the -h
option.
Examples
The following example shows how you can take a snapshot of an instance while the instance is in the running
state.
opc compute snapshot add /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d --machineimage /Compute-acme/jack.jones@example.com/snapshot1
[ { "account": "/Compute-acme/cloud_storage", "name": "/Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/4dbb2b4c-d315-47ba-b938-696f74826bec", "machineimage": "/Compute-acme/jack.jones@example.com/snapshot1", "creation_time": "2017-02-26T11:43:05Z", "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", "quota": null, "delay": "", "instance": "/Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d", "state": "active", "error_reason": "" } ]
This command returns a snapshot request identifier, which you can use to check the progress of the asynchronous snapshot request by running list
or get
command. For information about finding the state of the snapshot, see snapshot get.
After the snapshot of the running instance is taken, the state of the snapshot request changes to complete
. You can run the get machineimage
command to verify that the snapshot request has created the machine image correctly.
Add this new machine image to an image list, and then use it to create a new instance.
The following example shows how you can take a snapshot of an instance just before shutting it down. Use this option when you want to take preserve the custom changes you have made to an instance before deleting the instance. It creates a machine image which preserves the changes you have made, and then the instance is deleted.
opc -f json compute snapshots add /Compute-acme/jack.jones@example.com/dafcc088-1f0f-4550-b364-e901709873e1 --machineimage /Compute-acme/jack.jones@example.com/snapshot2 --delay=shutdown
{ "account": "/Compute-acme/cloud_storage", "name": "/Compute-acme/jack.jones@example.com/dafcc088-1f0f-4550-b364-e901709873e1/0b0ef87a-a7c8-46b3-8cdc-3315a203a431", "machineimage": "/Compute-acme/jack.jones@example.com/snapshot2", "creation_time": "2017-02-26T11:49:21Z", "uri": "https://api-z999.compute.us0.oraclecloud.com/snapshot/Compute-acme/jack.jones@example.com/dafcc088-1f0f-4550-b364-e901709873e1/0b0ef87a-a7c8-46b3-8cdc-3315a203a431", "quota": null, "delay": "shutdown", "instance": "/Compute-acme/jack.jones@example.com/dafcc088-1f0f-4550-b364-e901709873e1", "state": "active", "error_reason": "" }
If you use the --delay=shutdown
option, the snapshot remains in the active
state, until you shutdown the instance by running the delete instance
command. When the delete instance
command 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.
You can run the get machineimage
command to verify that the snapshot request has created the machine image correctly. Add this new machine image to an image list, and then use it to create a new instance.
snapshot get
Retrieves details for a specific snapshot.
You can use the get
command to verify whether add
operation was completed successfully. Use the -F
option (for example, -F state
) to filter the output for specific attributes.
Required Role
To complete this task, you must have the Compute_Monitor
or 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.
Syntax
opc compute snapshot get name
For help with the parameters and options of this command, run the command with the -h
option.
Example
The following example retrieves the state of the snapshot.
opc -f table -F state compute snapshot get /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/0b0ef87a-a7c8-46b3-8cdc-3315a203a431
Sample Output
+-------+--------+ state | active +-------+--------+
snapshot list
Retrieves details of all the instance snapshots in the specified container that match the specified query criteria. You can pass one or more query parameters to filter the search results. If you don't specify any query criteria, then details of all the snapshots in the container are displayed.
Required Role
To complete this task, you must have the Compute_Monitor
or 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.
Syntax
opc compute snapshot list container [--name name] [--instance instance] [--machineimage machineimage]
For help with the parameters and options of this command, run the command with the -h
option.
Example
The following example shows how you can list information, such as name of the snapshot and the corresponding machine image.
opc -f text -F name,machineimage compute snapshot list /Compute-acme/jack.jones@example.com
Sample Output
Some lines have been truncated with ellipses (...
) for readability. When you run the command in your environment, you'll see the full output.
MACHINEIMAGE NAME /Compute-acme/jack.jones@example.com/a6fbb572-a58...f748/d806...8 /Compute-acme/jack.jones@example.com/snapshot1 /Compute-acme/jack.jones@example.com/dafcc088-1f0...873e/c923...0 /Compute-acme/jack.jones@example.com/snapshot2
snapshot discover
Required Role
To complete this task, you must have the Compute_Monitor
or 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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.
Syntax
opc compute snapshot discover container
For help with the parameters and options of this command, run the command with the -h
option.
Example
The following example lists the snapshots of the instance /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d
.
opc -f json compute snapshot discover /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/
Sample Output
{ "result": [ /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/4dbb2b4c-d315-47ba-b938-696f74826bec /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/df8caca5-8a27-4153-9c5f-7440080b40c8 ] }
snapshot delete
Deletes a snapshot request. Deleting the snapshot request does not delete the machine image that was created by it. No response is returned for the delete action.
-
Requests in the
active
state cannot be deleted. -
Requests can only be deleted when they are in the
error
orcomplete
state.
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 Infrastructure Classic Console. See Modifying User Roles in Managing and Monitoring Oracle Cloud.
Syntax
opc compute snapshot delete name
For help with the parameters and options of this command, run the command with the -h
option.
Example
opc compute snapshot delete /Compute-acme/jack.jones@example.com/a6fbb572-a584-486a-9314-56a24499028d/4dbb2b4c-d315-47ba-b938-696f74826bec