Download EBS volume or snapshot to file
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?
Solution 1:
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.
Solution 2:
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/