Replicate an ECS instance across regions with a custom image
Create a custom image from a source instance and copy it to another region to deploy an identical environment.
Usage notes
Before you replicate an ECS instance across regions, note the following items:
-
Creating a custom image from an instance automatically creates a snapshot for each attached disk. You are charged for the snapshots. See Snapshot billing.
NoteSnapshots cannot be created for local disks. Instances with local disks do not support the operations described in this topic.
-
The source instance must reside in a Virtual Private Cloud (VPC), and the new instance must also reside in a VPC.
-
The new instance has the same disk data as the source instance but receives new instance metadata, including a new instance ID, public IP address, and private IP address. Identify resource associations before replication so you can update them promptly after replication. See Obtain instance metadata.
Step 1: Create a custom image from the source ECS instance
Go to ECS console - Instances.
-
In the upper-left corner of the top navigation bar, select a region.
-
Find the source instance and click the instance ID to go to the details page. In the upper-right corner, click All Actions. Search for and click Create Custom Image.
-
In the Create Custom Image dialog box, configure parameters and click Confirm.
-
Specify the custom image name.
-
For other parameters, see Create a custom image from an instance.
-
Go to ECS console - Images.
-
On the Custom Images tab, find the custom image you created and check its status.
When the image is in the Available state, proceed to the next step.
Step 2: Copy the custom image to a different region
Copy the custom image you created to the destination region before creating a new instance there.
Go to ECS console - Images.
-
In the upper-left corner of the top navigation bar, select a region.
-
On the Custom Images tab, find the custom image and click Copy Image in the Actions column.
-
In the Copy Image dialog box, configure the parameters and click Confirm.
-
Enter a name for the image copy.
-
Select a destination region.
-
For other parameters, see Copy a custom image.
-
-
Switch to the destination region to check the image copy progress and status.
After the image is copied, perform the subsequent steps in the destination region.
Step 3: Create a new ECS instance from the custom image
Go to ECS console - Images.
-
In the upper-left corner of the top navigation bar, select a region.
-
On the Custom Images tab, find the custom image copy.
-
In the Actions column, click Create Instance.
-
On the instance buy page, configure the parameters to create an instance.
-
The Image and Region parameters are auto-filled. No modification is needed.
-
Select an instance type based on your business requirements.
-
For other parameters, see Create an instance with Custom Launch.
-
Step 4: Check the data in the new ECS instance
Verify that business runs as expected on the new instance. Examples:
-
Check the disk data.
Verify that the system disk data (files, directory structures) on the new instance matches the source instance. If data disks are attached, verify data disk consistency as well.
-
Run applications or services.
Run the same applications or services on the new instance and verify that they provide the same functionality and data operations as on the source instance.
-
Compare resource information.
Compare resource information, such as image information and network configurations, between the source and new instances. See View instance information.
-
Update resource associations.
The new instance receives new metadata that differs from the source instance. Update resource associations promptly after replication. Examples:
-
If an application depends on a specific private IP address for internal communication, update the network configurations of the new instance after replication. For example, change the private IP address to one in the same subnet as the source instance and verify network connectivity. See Modify the private IP address of an instance.
-
If an application depends on DNS services, update the DNS settings of the new instance after replication to ensure continued external service. See How do I customize the DNS settings of a Linux instance?
-
Ensure business continuity
After you verify data consistency on the new instance, follow these guidelines to minimize service disruption during the cutover from the source region to the destination region.
Keep the source instance running
Do not release the source ECS instance until the cutover is fully confirmed. Keeping it running lets you quickly roll back to the source region if the target instance encounters unexpected issues after the cutover.
Creating a custom image does not stop the source instance by default, so the source instance continues to serve business traffic while you create the image. The image creation dialog box recommends stopping the instance to ensure data integrity, but this is only a recommendation, not a requirement — you can create a custom image while the instance is in the Running state. As a result, the source instance can keep running throughout image creation, cross-region image copy, and new instance creation, right up until the cutover is complete.
Plan the cutover window
Schedule the cutover during off-peak hours and communicate the maintenance window to your team in advance. Before starting the cutover, agree on a success criterion (for example, health checks pass and application latency is within the expected range) and a rollback threshold (for example, error rate exceeds 1% or response time exceeds 500 ms). Defining these criteria in advance removes ambiguity during the cutover.
Redirect traffic to the target region
Use one of the following methods to shift traffic from the source region to the destination region:
-
DNS-based cutover: Update DNS records to point to the public IP address or Elastic IP Address (EIP) of the new instance. To speed up DNS propagation, reduce the TTL to 60 seconds or less before the cutover window. For more information about how to configure DNS for ECS instances, see How do I customize the DNS settings of a Linux instance?.
-
SLB-based cutover: If your architecture includes a Server Load Balancer (SLB) instance, add the new instance to the backend server group, gradually shift traffic to the new instance, and then remove the source instance from the group. Gradual traffic shifting reduces the risk of service interruption compared to an immediate cutover.
-
Update private IP references: The new instance receives a new private IP address, a new public IP address, and a new MAC address, all different from those of the source instance. IP addresses cannot be migrated across regions, so you cannot reuse the source instance's IP addresses on the new instance. If internal systems communicate with the source instance through a private IP address, update the corresponding private IP addresses in your application configurations, and update your DNS records or load balancer backend server configurations to point to the new instance's addresses after the migration. For more information, see Modify the private IP address of an instance.
Monitor business metrics after the cutover
After traffic is switched to the new instance, monitor the following metrics to confirm that the service is running as expected:
-
Application error rate and response time
-
CPU utilization and memory usage
-
Key service log outputs and alert notifications
You can use Cloud Monitor to configure alert rules for the target instance, so that you are notified of anomalies in real time.
Roll back if issues occur
If unexpected issues occur after the cutover, restore service by redirecting traffic back to the source instance — for example, revert the DNS record or restore the SLB configuration to point to the source instance. Investigate and resolve the root cause before reattempting the cutover.
(Optional) Step 5: Release or delete the source ECS instance and the resources of the instance
Instance release, snapshot deletion, and image deletion are irreversible. Data in the released instance, deleted snapshot, or deleted image cannot be recovered. Release or delete resources only after all business data is migrated.
Before releasing the source instance and its resources, verify data consistency on the new instance, update resource associations, and confirm that business runs as expected.
References
To migrate ECS instance data across Alibaba Cloud accounts, use Server Migration Center (SMC). See Migrating ECS instances: cross-account and same-account.