16

Is there any way to dump/save EBS volume/snapshot to file or mount it to local Linux file-system?

I found only this old thread and this script which intends to save it via S3 and doesn't seem very reliable. I also found this online-tool, but it didn't work for me. It doesn't even contain all available regions.

I do NOT seek rsync-based solutions.

Can we directly download EBS as .img or .iso file in a dd manner?

Suncatcher
  • 735
  • 2
  • 10
  • 24

5 Answers5

13

AWS don't provide a way to download or extract the actual block device that makes up an EBS volume. The standard way to grab a copy is to use rsync, but as you're after a block level way of doing this, this article might be of some use.

In short (and in case the link above disappears), use netcat and dd at both ends, e.g;

On the sender (your EC2 instance to which the volume is attached):

dd bs=16M if=/dev/sda|bzip2 -c|nc receiver.example.net 19000

On the receiver (your PC, backup server, etc):

nc -l 19000|bzip2 -d|dd bs=16M of=/path/to/my/volume.img

Which will transfer the entire contents of the block-level device over port 19000 in 16MB bzipped chunks, though it can also be done over ssh instead, but according to their performance stats, is much, MUCH slower! Naturally you need to consider the security aspect of doing it this way as well. If your block device has sensitive data on it, encrypting it with SSH or using a VPN tunnel is highly recommended instead, and the transfer speed slowdown is a reasonable trade-off.

One other thing to note is that filesystems can be cached in memory, so could result in a corrupted image. Unmount your volume (but leave it attached to the instance) before running the above to ensure filesystem consistency.

To grab a copy of a snapshot, you'll need to create a volume from it, attach it to an instance, then do the above. There is no other way to access a snapshot's data.

dannosaur
  • 998
4

All current answers are outdated: since late 2019, AWS provides APIs to access the data within EBS snapshots directly, without the need to create a volume and an EC2 instance.

These are called EBS direct APIs, and today they are generally available across regions. AWS has even published a standalone tool called 'coldsnap' that (among other things) allows downloading a snapshot into a file:

coldsnap download <snapshot ID> disk.img

Please note that this API is not free to use. At the time of this writing, you are charged around $0.003 for every 1000 blocks downloaded (it varies slightly across regions). Blocks are 512 kiB, so that means around $0.006 per GiB downloaded. (512 kiB is only the minimum; blocks may be larger, in which case costs per GiB would be lower).

Also note that the API cannot be used on public snapshots.

0

You can use VM Import/Export via the aws cli. It enables you to import and export virtual machine images. It will work with snapshots as well.

https://docs.aws.amazon.com/vm-import/latest/userguide/what-is-vmimport.html

https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-import-snapshot.html

-1

best try this site. use ftp client like winscp. https://asf.alaska.edu/how-to/data-recipes/moving-files-into-and-out-of-an-aws-ec2-instance-windows/

-1

Looks like cloudberry does it.

https://www.cloudberrylab.com/blog/cloudberry-backup-cloud-to-local-backup-functionality/