Clone an ECS instance

更新时间:
复制 MD 格式

You can clone an ECS instance to quickly create an identical or similar copy. This is useful for scenarios such as replicating test environments, scaling applications, disaster recovery, migration, and upgrades. Cloning can improve the reliability, scalability, and efficiency of your services. This topic describes how to clone an ECS instance and explains the associated billing and limitations.

Note

To migrate data from an existing instance (Instance A) to another existing instance (Instance B), follow these steps:

  1. Create a custom image from Instance A.

  2. (Optional) Copy the custom image.

    If Instance B is in a different region than Instance A, you must copy the custom image to the region of Instance B.

  3. Replace the operating system of Instance B with the copied custom image.

Differences between source and cloned instances

Attribute

Description

Instance name

The cloned instance has the same name as the source instance.

Instance type

The instance type may differ.

If the source instance type is out of stock in the destination availability zone, the system automatically selects an instance type with a similar configuration.

Private IP address

The private IP address may differ.

  • If you do not specify a destination vSwitch, the system automatically creates a vSwitch based on the source vSwitch configuration and assigns a private IP address to the cloned instance.

  • If you specify a destination vSwitch, the system assigns a private IP address to the cloned instance from that vSwitch.

Public IP address

The public IP address differs.

The system randomly assigns unique public IP addresses.

Note

If the source instance is associated with an elastic IP address (EIP), the system does not create or associate an EIP with the cloned instance. After cloning, you must manually create and associate a new EIP if needed.

Security group

The security group might be different, but the security group rules are the same.

  • If you select the Virtual Private Cloud (VPC) of the source instance, the cloned instance uses the security group of the source instance.

  • If you select a different VPC or clone the instance to a different region, the system creates a new security group for the cloned instance based on the source instance's security group.

Prerequisites

  • Ensure that your Alibaba Cloud account has a balance of at least CNY 100.

  • The source instance's image must be available. You can verify its availability on the Images page or by calling the DescribeImages API operation. You cannot clone an instance if its image is unavailable.

  • If you are a RAM user, contact your primary account owner or a RAM administrator to grant you the AliyunECSFullAccess, AliyunVPCFullAccess, and AliyunROSFullAccess system policies. Without these permissions, you cannot clone the instance. For details, see Quick start: Create a RAM user and grant permissions.

Billing

  • The cloned instance uses the same billing method as the source instance.

  • If you select Contain instance data when you clone an instance, the system creates a custom image whose name starts with TemplateScratch-. For information about how custom images are billed, see Image billing.

    Cloning type

    Contain instance data

    Description

    Same-region cloning

    Select Include instance data.

    The system creates a custom image from the source instance and then uses the custom image to create the destination instance.

    If you do not select Include instance data

    The system creates the destination instance directly from the source instance's image.

    Cross-region cloning

    Select Include instance data.

    The system creates a custom image from the source instance, copies the custom image to the destination region, and then uses the copied image to create the destination instance.

    The Include instance data checkbox is not selected.

    The system creates the destination instance directly from the source instance's image.

    Note

    The source instance's image must be a public image or a Marketplace image and must exist in the destination region.

Important
  • If any of the selected source instances use an image that is no longer available, you must select Contain instance data to clone them.

  • If you no longer need the custom image after cloning is complete, delete it in the current or destination region to avoid further charges.

Limitations

  • You can clone only ECS instances that are in a Virtual Private Cloud (VPC).

  • You can clone a maximum of 100 ECS instances in a single task.

  • You can clone instances only in the ECS console. This feature is not available through the API.

Procedure

  1. Go to ECS console - Instances.

  2. In the upper-left corner of the page, select a region and resource group.地域

  3. Click the ID of the source instance to go to its details page. Click All Operations, and then find and click Clone Instance.

  4. In the Clone Instance dialog box, configure the destination instance parameters, and then click Next.

    Parameter

    Description

    Destination Region

    Select the destination region.

    Destination Zone

    Select the destination availability zone.

    Destination VPC

    • If you do not specify a destination vSwitch, the system automatically creates a vSwitch based on the source instance's vSwitch configuration and assigns a private IP address to the cloned instance.

    • If you specify a destination vSwitch, the system assigns a private IP address to the cloned instance from that vSwitch.

    • During a cross-region clone, if you do not specify a vSwitch and a VPC, the system automatically creates a VPC and a vSwitch based on the source instance's network configuration. The system automatically selects the availability zone for the new vSwitch.

    • If you specify a VPC that is different from the source instance's VPC or if you perform a cross-region clone, the system creates a new security group for the cloned instance. Otherwise, the cloned instance uses the same security group as the source instance.

    Destination vSwitch

    Number of instances

    Set the number of instances to clone.

    If inventory for the specified instance type is insufficient, the system creates as many instances as are available.

    Contain instance data

    • Clear this option to create a destination instance with the same specifications as the source instance, but without its data.

    • Select this option to create a destination instance with the same specifications and data as the source instance. For data consistency, stop the source instance before you start cloning.

    Important

    If the specified instance type is out of stock, the system automatically finds and uses a similar instance type.

  5. In the Configuration Preview step, confirm the destination instance details and billing information, and then click Start Cloning.

    Note

    If this is your first time cloning an instance, you must read and select I have read and agreed to the ECS Terms of Service.

    The instance cloning feature is powered by Resource Orchestration Service (ROS). During the cloning process, you can go to the ROS console to view the progress. After cloning is complete, the system automatically deletes the stack but does not delete the resources it created, such as the VPC, vSwitch, security group, custom image, and instances.

  6. View the cloning result.

    After the instance is successfully cloned, log on to it to verify that its business data is consistent with the source instance.