Snapshot and Restore of Lightsail Instance to Lightsail/EC2
Tags: aws, cloud, ec2, lightsail
Published: 2022-05-12 14:31:04

Taking regular backup/snapshots of a production application is important. It is one of the main requirements of a disaster recovery(DR) plan. But snapshots are not only for DR, you can use them to move/clone instances to different regions or availability zone(AZ). Maybe move to a higher spec instance. Or maybe you want to move to Amazon EC2 altogether. 

## Prerequisites 

You just need an existing Amazon Lightsail instance. Don't worry if you don't have one, follow how to [**Deploy WordPress App to Amazon Lightsail**](https://blog.harun.dev/deploy-wordpress-app-to-amazon-lightsail). 

## Take Snapshot (Backup)

1. Click on the instance name you want to take a snapshot. All of the instances are listed under the **Instances** tab of the home page. 
![Amazon Lightsail Instances](https://cdn.hashnode.com/res/hashnode/image/upload/v1652276595201/R3KWMrmbY.png)

2. Go to the **Snapshots** tab of your instance page. 
![Amazon Lightsail Instance Snapshot](https://cdn.hashnode.com/res/hashnode/image/upload/v1652276809173/QeAJzi5B9.png)
(B) We are going to create a manual snapshot. This one will take a snapshot instantly.
(C) Optionally, you can set up an automatic snapshot too. It will take daily snapshots. 
> ⚠️ ***For production instance, always set up an automatic snapshot. ***

3. Give it a name and click **Create**. 
![Amazon Lightsail Instance Snapshot](https://cdn.hashnode.com/res/hashnode/image/upload/v1652277314811/vY0klcQ0u.png)
It will take some time if this is the first snapshot of the instance, size is another factor. Subsequent snapshots are faster, as it takes incremental backups, only changes from the last snapshot. 

4. Upon completion, it will look like this: 
![Amazon Lightsail Instance Snapshot](https://cdn.hashnode.com/res/hashnode/image/upload/v1652277636707/z3QUzzdTY.png)

5. You will find all of the snapshots in the **Snapshots** tab of the homepage. I have just one: 
![Amazon Lightsail all snapshots](https://cdn.hashnode.com/res/hashnode/image/upload/v1652277823766/xBicTLwpc.png)

## Restore to new Amazon Lightsail instance

1.  Click on these 👇 three dots: 
![Lightsail Snapshot restore menu](https://cdn.hashnode.com/res/hashnode/image/upload/v1652278253575/66DQ_Myis.png)

2. Click on **Create new instance** from this menu: 
![Lightsail Snapshot restore menu](https://cdn.hashnode.com/res/hashnode/image/upload/v1652278347973/Lb09a0P_tP.png)
> ℹ️ You can click on the second item, **Copy to another Region** to literally copy to another region and restore to a new instance there. Snapshot stored in an S3 bucket in the same region where the instance launched. You can't access the S3 bucket as it's managed by AWS. To restore a snapshot to a new instance in another region, you have to copy it first.

3. The page looks familiar, right? It's the same create instance page.
![Create an instance from a snapshot in Amazon Lightsail](https://cdn.hashnode.com/res/hashnode/image/upload/v1652279009412/Z5_gktIsy.png)
(A) You can change the availability zone(AZ) if you want. It's great if you are using multiple instances for horizontal scaling, gives high availability(HA). 
(B) Choose an instance the same size or larger than the source. Choose larger for vertical scaling. If you need a larger instance than you originally have, this is the way.
(C) Give it a name, and 
(D) Click the **Create instance** button from the bottom of the page.

Wait a moment, maybe a few minutes. Congratulations 🎉 you just restored your instance. 

...

## Copy to another Region

Snapshot stored in an S3 bucket in the same region where the instance launched. You can't access the S3 bucket as it's managed by AWS. To restore a snapshot to a new instance in another region, you have to copy it first. Let's copy it to another region.

1. Go to the **Snapshots** tab of the homepage. Find your instance and snapshot. Click the three dots. And then click **Copy to another Region**:
![Copy snapshot to another Region in Amazon Lightsail](https://cdn.hashnode.com/res/hashnode/image/upload/v1652280120596/KG3CA5XoC.png)

2. (A) Choose the region you want to copy the snapshot, (B) give it a name, and (C) click the **Copy snapshot** button from the bottom of the page. 
![Copy snapshot to another Region in Amazon Lightsail](https://cdn.hashnode.com/res/hashnode/image/upload/v1652279993049/8ENAFcW2C.png)

3. It will take a few minutes to copy the snapshot.

...

## Restore/Export to Amazon EC2 instance
1. Click three dots from the snapshot menu you want to restore to EC2 and click the **Export to Amazon EC2** menu item 
![Export to Amazon EC2](https://cdn.hashnode.com/res/hashnode/image/upload/v1652281038616/V9usMFaL7.png)

2. Click the **Yes, continue** button in the popup. Click **Acknowledge** in the next popup.
![Export to Amazon EC2](https://cdn.hashnode.com/res/hashnode/image/upload/v1652281327886/UOQteEtmX.png)
> ⚠️ If you are not in the free-tier or cross the free-tier limit, you may get charged for this. If you are not sure, don't do it. Just follow my demo.

3. You will see a task running like this ↓. Wait for a while to finish. A small snapshot wouldn't take much time. 
![Export to Amazon EC2](https://cdn.hashnode.com/res/hashnode/image/upload/v1652281563424/lc_Mz-K0d.png)

4. After the copy task is completed, go to [Snapshots of EC2 Management Console](https://us-east-1.console.aws.amazon.com/ec2/v2/home?region=us-east-1#Snapshots:). Choose the correct region. You should see your snapshot there.

5. Select the snapshot and click the **Create image from snapshot** from the **Actions** menu 
![Snapshots on EC2 Management Console](https://cdn.hashnode.com/res/hashnode/image/upload/v1652281992820/AGSDZSL0V.png)

6. Give the name of the image and click the **Create image** button from the bottom of the page
![Snapshots on EC2 Management Console](https://cdn.hashnode.com/res/hashnode/image/upload/v1652282168870/rem3kb_a1.png)

7. Now go to [AMIs page of EC2 Management Console](https://us-east-1.console.aws.amazon.com/ec2/v2/home?region=us-east-1#Images:visibility=owned-by-me). Choose the correct region, N. Virginia (us-east-1) in my case. You should see all of your AMIs.

8. Select the AMIs you just created and click the **Lunch Instance from AMI** button in the top right corner. 
![CleanShot 2022-05-12 at 19.34.19@2x.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1652362498403/WWWDZ_9xk.png)

9. You will see a traditional EC2 Lunch page: 
![CleanShot 2022-05-12 at 19.44.03@2x.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1652363162708/wxsZxlGt6.png)
(A) Give your instance a name. (B) Choose an instance type, for my case, it's free tier eligible t2.micro. (C) Choose existing key pair or create a new one. You need it to log in via SSH. (D) Check the ports you want to open, in my case I selected all of them. 

Now, click the **Lunch instance** button from the right sidebar. Wait for a while to instance state to become ***Running*** and Status check ***2/2 checks passed***. 

10. You will see the EC2 Instances page like this:
![CleanShot 2022-05-12 at 19.56.19@2x.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1652363823997/TMySzalyO.png)
Select the instance. Copy the public IP address and try it in the browser. You should see the same page as Amazon Lightsail instance. 

> ℹ️ Manual snapshots will not be deleted even if you delete the instance. So, don't forget to delete unnecessary snapshots to save bills.

...

## Conclusion
Hope you enjoyed this article. Ask your questions in the comment. Subscribe to my newsletter to get weekly updates.