1

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?

3

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.

  • OK, thanks. Will try this way. Should I start listening on receiver (nc -l) prior to starting dd on sender? – Suncatcher Apr 25 '18 at 18:01
  • Yes. The dd process (and thus the pipe) will start funnelling data though it almost immediately. If the receiver isn't listening, netcat on the sender will either timeout, or immediately raise a connection refused error (or similar), then the entire process will stop. – dannosaur Apr 25 '18 at 18:06
  • 2
    This method will "technically" work but remember that file systems are cached in memory. This method often results in corrupted file systems on restore. Dismount all volumes before block copying any device. This means that you cannot dismount the root file system volume so that device cannot be block copied. – John Hanley Apr 26 '18 at 20:24
  • @JohnHanley good point! I've updated the answer to reflect this. – dannosaur Apr 27 '18 at 9:18
  • Thank you. I have upvoted your answer with the improvements. – John Hanley Apr 27 '18 at 17:13
-1

Looks like cloudberry does it.

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.