How to Migrate (Copy) an EC2 Instance Between Amazon AWS Regions

How to Migrate (Copy) an EC2 Instance Between Amazon AWS Regions

Move EC2 instance Between AWS Cloud RegionsAWS is ideally suited for making the user’s applications tolerant to disaster. One of the options for making the user’s application suitable to DR is to keep a backup of the data / application setup in multiple regions. If the first region is not reachable for some reason, the user can start the application from the other region.  In Dec, 2021 AWS introduced functionality to copy snapshots across regions.

The real need for this ability to migrate snapshots is to protect your cloud from downtime as a result of AWS outages. Replicating snapshots across availability zones (AZs) and regions will enable you to deploy your online services across AZs and regions. Doing so will protect your cloud from damage and ensure availability during an outage. Newvem’s Cloud Operations Optimization service scans your AWS footprint and detects how prepared you are for an outage as well as provide detailed information on what needs to be done to ensure your cloud’s protection.

This guide demonstrates how to copy a snapshot of a Linux based instance to another region as well as attach a volume to a new instance to complete the instance data migration across regions.

AWS Cloud Best Practice: Introduction to High Availability Deployment

1. Go to the AWS Console and select the EC2 Service. Go to the EC2 running instance dashboard and select the running Linux instance. It displays the instance meta data. Note the volume details of the instance. The instance is currently running in the US-West-2 (Oregon) region.

2. Login to the Linux instance, as explained in Connecting to AWS linux instance from a Windows machine. List the data of the instance.

3. Go to Snapshot in the EC2 console and select “Create Snapshot”, as explained in How to create or delete an EBS volume snapshot. Provide the snapshot name, description and select the volume of the instance identified in step #1. Click on the “Create” button.

[Storage S3 & Compute EC2 Cost Vs. Availability Tradeoff - Newvem usage pattern analysis helps you reach an optimal balance between cost and availability. Learn more about Newvem's features]

4. The snapshot has been created and is available in the Snapshot console.

5. Select the snapshot that the user wants to move to the other region. Right click on the snapshot and select the “copy snapshot” option.

6. Provide the target region and the description for the snapshot. Click on the button “Yes, Copy”.

7. The snapshot copy process will now commence. AWS will display the acknowledgement for the same and provide a link to go to the snapshot console of the target region. Click on the link or manually change the region to go to the target region snapshot console.

8. In the target region (EU-Ireland), the copy process is in progress. AWS will display the progress of the process.

9. After the process is complete, the snapshot will be available in the target region.

10. Create the volume from the snapshot, as explained in How to create an EBS volume from a snapshot.

11. Select the zone where the volume will be created and provide the remaining details. Click on the button “Yes, Create” to create the volume.

12. Launch a Linux instance (as explained in How to launch an Amazon AWS EC2 instance) in the same zone where the volume from the snapshot has been created.

13. Stop the instance, as explained in How to reboot an EC2 instance. Detach the root volume of the new instance.

14. Once the root volume has been detached, attach the volume created in step #11 to the instance.

15. Attach the volume as the root volume by mounting on /dev/sda1.

16. Start the Linux instance and login to the instance. The instance will display the content similar to the US-West-2 Linux instance, as shown in step #2.

17. The above process completes the migration of the user’s instance from one region to another.

18. If the user wants to migrate the snapshot with the command line option, first set the EC2 command line tool, as explained in How to install AWS CLI to Windows.

Using AWS CLI Tools

19. Run the following command to list the current snapshots of the region:

ec2-describe-snapshots –region <Region Name>

To copy the snapshot data, the ec2-copy-snapshot command will be executed. The above mentioned command should be executed from the target region unlike the console UI where it is executed from the source region.

Run the command:

ec2-copy-snapshot –region <Target Region where the data will be copied> -r <Source Region where the snapshot is present> -s <Snapshot ID>.

20. The snapshot copy process will now commence, as explained in step #9.

21. Once the snapshot is available, run the command ec2-describe-snapshots –region <Region Name> to list the current snapshots of the region for getting the status of the snapshot.


Ensuring High Availability

Deploying applications on AWS can appear daunting at first; there are lots of new terms and concepts to familiarize yourself with. Before you launch your first instance on AWS, you should understand all the different Amazon cloud service options. For more information on that, check out the article ‘AWS Cloud Best Practice: Introduction to High Availability Deployment’.

Understanding how to duplicate snapshots across regions and availability zones is the first step in protecting your cloud from AWS outages. Step 2 is to understand your baseline disaster recovery (DR) status. Newvem Cloud Care continuously analyzes your baseline disaster recovery and identifies if best practices have been implemented. Additionally, it recommends AWS features and best practices that can help you reach optimal availability, increase outage protection and ensure a quick recovery. Furthermore, Newvem reviews the status of your instances and identifies unhealthy and overloaded instances that are vulnerable to outages. Having a clear picture of your cloud availability will provide you with the knowledge and tools to protect your cloud from outages and vulnerabilities.

For IT Managers

Newvem Cloud Care helps see if you are operating in your usage equilibrium. We also help you make better decisions by giving you visibility into your AWS cloud costsassets, and risks. Sign up today and enjoy:

  • Comprehensive visibility to your cloud operations.
  • Resolve problems faster – identify issues and prioritize your activities by severity.
  • Save time with Newvem’s actionable operational insights.

Keywords: Amazon AWS elastic cloud services, Cloud Scalability, Cloud Performance, Cloud Availability, Cloud Utilization, Amazon S3, Amazon Web Services, Cloud Cost optimization, cloud backups, cloud disaster recovery, AWS Regions, cloud Availability Zones, High cloud Availability, amazon EC2, amazon EBS, Data Migration

There is 1 comment .

Jerry Papa —

Very nice!  Thank you.  Spent several hours copying different snapshots/images back and forth and messing with keypairs and .ssh/authorized keys and among other things but your explanation here is the simplest, easiest way to do it.  Thank you very much.

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations