Cloning an Instance by Using Instance Snapshots
About Instance Snapshots
Instance snapshots provide an easy way to create a customized machine image using an existing instance as a template. You can then use this customized machine image to create multiple instances with identical configurations.
To clone an instance using an instance snapshot, first create an instance using an appropriate machine image.
Note:
If you want to create an instance snapshot, your instance must use a nonpersistent boot volume. If your instance uses a bootable storage volume and you want to clone the storage volume, see Backing Up and Restoring Storage Volumes Using Snapshots.
When your instance is running, customize your instance as required, by adding users, or installing and configuring applications. These changes are stored on your nonpersistent boot disk.
When you’re done customizing your instance, to use the instance as a template to create other instances, create an instance snapshot. Instance snapshots capture the current state of your boot disk and create a corresponding machine image, which is uploaded to your Oracle Cloud Infrastructure Object Storage Classic account. You can then register this machine image with your Compute Classic account and use it to create instances. These instances will contain all the configuration and customization that you’d done on the original instance when you took the snapshot.
You can generate an instance snapshot while your instance is still running. If you do this, you can continue to work on your instance, but any changes you make after the snapshot is generated won’t be captured by the snapshot. If you want to generate the snapshot just before you delete your instance, you can use the option to create a deferred snapshot. This allows you to continue making changes to the instance even after you’ve created the snapshot request, and ensuring that all the changes you make will be captured by the snapshot just before the instance is deleted.
When you create an instance using a nonpersistent boot disk, if you want to delete the instance, then using instance snapshots also allows you to preserve the changes you’ve made to your instance before you delete the instance. Later on, you can use this machine image to create another instance identical to the one you deleted.
Creating an Instance Snapshot
Creating a snapshot of an instance allows you to capture the current state of the nonpersistent boot disk used by an instance, including all customization that you may have made at the operating-system level after creating the instance.
Note:
Instance snapshots capture the state of your nonpersistent boot disk. You can’t create an instance snapshot if your instance uses a persistent bootable storage volume. To create a snapshot of a storage volume, see Backing Up and Restoring Storage Volumes Using Snapshots.
Prerequisites
-
Instance snapshots are stored in the associated Oracle Cloud Infrastructure Object Storage Classic instance. Ensure that you’ve set a replication policy for your Oracle Cloud Infrastructure Object Storage Classic instance. See Selecting a Replication Policy for Oracle Cloud Infrastructure Object Storage Classic in Using Oracle Cloud Infrastructure Object Storage Classic.
-
Ensure that the instance you want to snapshot isn’t in an error state. You can’t create a snapshot of an instance that is in an error state.
-
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.
Procedure
To create an instance snapshot:
To create an instance snapshot using the CLI, use the opc compute snapshot add
command. For help with that command, run the command with the -h
option. For the instructions to install the CLI client, see Preparing to Use the Compute Classic CLI in CLI Reference for Oracle Cloud Infrastructure Compute Classic.
To create an instance snapshot using the API, use the POST /snapshot/
method. See REST API for Oracle Cloud Infrastructure Compute Classic.
Registering the Image Generated by an Instance Snapshot
An instance snapshot captures the current state of the nonpersistent boot disk of an instance and uses it to create a corresponding machine image. You can then use this machine image to create other instances. These instances are clones of the instance that you created the snapshot of. Any customization done on that instance is automatically part of instances created using the snapshot.
The image created by an instance snapshot is stored in your Oracle Cloud Infrastructure Object Storage Classic account. Before you can use this image to create an instance, you must register this image in your Compute Classic account.
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.
To do this using the CLI, use the opc compute image-list add
and opc compute image-list-entry add
commands, in that order. For help with these commands, run each command with the -h
option. For the instructions to install the CLI client, see Preparing to Use the Compute Classic CLI in CLI Reference for Oracle Cloud Infrastructure Compute Classic.
To do this using the API, invoke the POST /imagelist/
and the POST /imagelistentry/
methods, in that order. For more information, see REST API for Oracle Cloud Infrastructure Compute Classic.
After registering the image generated by an instance snapshot, to create an instance using this machine image, see Creating an Instance Using a Private Image.
Creating an Instance from an Instance Snapshot
An instance snapshot captures the current state of an instance and uses it to generate an image is uploaded to your Oracle Cloud Infrastructure Object Storage Classic account. You can then register this image with your Compute Classic account and use it to create instances.
Deleting an Instance Snapshot
An instance snapshot allows you to capture the current state of an instance and use it to launch other instances. When an instance snapshot is completed, it creates a machine image and stores it in your Oracle Cloud Infrastructure Object Storage Classic account.
After an instance snapshot has completed creating a machine image of an instance, the instance snapshot record on the web console only provides information about when a machine image was created from a given instance. You can also view the autogenerated name of an instance snapshot, which helps to identify the corresponding machine image file in your Oracle Cloud Infrastructure Object Storage Classic account. If you don’t require this information for record-keeping purposes, you can delete the instance snapshot. Deleting an instance snapshot has no impact on the machine image file stored in your Oracle Cloud Infrastructure Object Storage Classic account, or on the private image that you might have registered in your Compute Classic account.
Prerequisites
-
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. -
Ensure that the instance snapshot that you want to delete is in the complete state.
Procedure
To delete an instance snapshot:
To delete an instance snapshot using the CLI, use the opc compute snapshot delete
command. For help with that command, run the command with the -h
option. For the instructions to install the CLI client, see Preparing to Use the Compute Classic CLI in CLI Reference for Oracle Cloud Infrastructure Compute Classic.
To delete an instance snapshot using the API, use the DELETE /snapshot/
method. See REST API for Oracle Cloud Infrastructure Compute Classic.