Skip to content

Commit 94af408

Browse files
committed
Recovering data from AWS Lightsail using EC2
1 parent 0ea61da commit 94af408

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

aws/recovering-lightsail-data.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Recovering data from AWS Lightsail using EC2
2+
3+
I ran into problems with my AWS Lightsail instance: it exceeded the CPU burst quota for too long and was suspended, and I couldn't figure out how to un-suspend it.
4+
5+
I had a snapshot of the hard drive and I wanted to recover the data from it. This ended up taking far longer than I expected - I imagine there's a better way of doing this but here's how I solved it.
6+
7+
Short version: I migrated the snapshot to EC2, then launched an EC2 instance and mounted that snapshot as an EBS volume.
8+
9+
Long version (because I had to figure out a lot of steps along the way):
10+
11+
1. I activated the Lightsail "Export to Amazon EC2" option on the snapshot
12+
2. I waited a while for the export to complete
13+
3. This launched a new EC2 instance for me... but for some reason I couldn't SSH into that instance. So I terminated it.
14+
4. I used the EC2 web console to figure out the AWS identifier for the EC2 copy of the Lightsail snapshot - something like `snap-02a530e12a34`
15+
5. I created a brand new EC2 instance and on the "Add storage" panel I added an EBS volume for `/dev/sdb` with the snapshot identifier I found in the previous step. I started this instance with a keypair so I could SSH into it.
16+
6. I mounted the EBS volume - see section below
17+
7. ... I used `scp` (with the keypair) to copy off the data
18+
19+
## Mounting the EBS volume
20+
21+
I hadn't worked with EBS before so this took some figuring out. My instance was configured with `/dev/sdb` as an EBS volume. I confirmed that the data was accessible like so:
22+
23+
[ec2-user@ip-172-31-26-179 dev]$ sudo file -s /dev/xvdb
24+
/dev/xvdb: x86 boot sector; partition 1: ID=0x83, active, starthead 32, startsector 2048, 167770079 sectors, code offset 0x63
25+
26+
Then I created a `/data` directory and mounted the volume:
27+
28+
[ec2-user@ip-172-31-26-179 dev]$ sudo mkdir /data
29+
[ec2-user@ip-172-31-26-179 dev]$ sudo mount /dev/xvdb1 /data
30+
31+
I actually tried `sudo mount /dev/xvdb /data` first and got a `mount: /data: wrong fs type` error - [this StackOverflow answer](https://serverfault.com/questions/632905/cannot-mount-an-existing-ebs-on-aws/632906#632906) helped me solve that.

0 commit comments

Comments
 (0)