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:

  1. Sign in to the Compute Classic console. If your domain spans multiple sites, select the appropriate site. To change the site, click the Site menu near the top of the page.
  2. Go to the instance that you want to create a snapshot of. From the menu icon menu, select Create Snapshot.
    Alternatively, you can also create an instance snapshot from the instance details page.
    1. On the Instances page, go to the instance that you want to create a snapshot of, and from the menu icon menu, select View.

    2. On the instance details page, go to the Instance Snapshots section and click Create Snapshot.

  3. In the Create Instance Snapshot dialog box, enter a name for the snapshot.
  4. If you haven’t yet finished customizing your instance and you want to create the snapshot just before you delete the instance, you can select the Deferred Snapshot option. This option allows you to continue working on the instance. The snapshot is taken only when you delete the instance or stop the instance orchestration.
  5. Click Create. A request to create an instance snapshot is created. If the deferred snapshot option was selected, the snapshot will be generated when you delete the instance. If the deferred snapshot option wasn’t selected, the process of creating the instance snapshot begins right away.
    When an instance snapshot is generated, it creates a custom image. While the image is being created, or when you select the option to create a deferred snapshot, the instance details page shows the state of the instance snapshot as Active. When the image has been created and is available in your Oracle Cloud Infrastructure Object Storage Classic account, the state of the instance snapshot changes to Complete. Next, to register this image, see Registering the Image Generated by 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.

  1. Sign in to the Compute Classic console. If your domain spans multiple sites, select the appropriate site. To change the site, click the Site menu near the top of the page.
  2. Click the Instance Snapshots tab in the left pane.
    The Instance Snapshots page displays a list of snapshots. Instance snapshots are listed alphabetically by instance name. If an instance has multiple snapshots, the most recent snapshot is listed on top.
  3. Go to the snapshot that you want to use. From the menu icon menu, select Associate Image.
    Alternatively, you can also register a snapshot from the instance details page.
    1. On the Instances page, go to the instance that you want to clone. From the menu icon menu, select View.

    2. On the instance details page, in the Instance Snapshots section, go to the snapshot that you want to use. From the menu icon menu, select Associate Image.

  4. Enter a description for the image and click Ok.
The image is added as a private image on the Private Images page.

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.

After you’ve registered the image generated by an instance snapshot, the machine image is added to the list of custom images on your Private Images page. To create an instance using this machine image, see Creating an Instance Using a Private Image.

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:

  1. Sign in to the Compute Classic console. If your domain spans multiple sites, select the appropriate site. To change the site, click the Site menu near the top of the page.
  2. Go to the instance that you want to view. From the menu icon menu, select View.
  3. On the instance details page, in the Instance Snapshots section, go to the instance snapshot that you want to delete. Make a note of the name of the image file associated with the snapshot. You might need this later, if you want to register the image created by this snapshot, or if you want to delete the image created by this snapshot from your associated Oracle Cloud Infrastructure Object Storage Classic account. Then, from the menu icon menu, click Delete.
    Alternatively, you can also delete a snapshot from the Instance Snapshots page.
    1. On the Instances page, click the Instance Snapshots tab in the left pane.

    2. On the Instance Snapshots page, go to the snapshot that you want to delete. Make a note of the image file name associated with the snapshot, and then, from the menu icon menu, click Delete.

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.