4

I have several Amazon AWS EC2 virtual machines that I created on AWS EC2. They were not imported, they were created there. I would like to export these machines in order to achieve local backups, and a local testing environment.

I have looked a lot of places, and found tons of information that says you can only export a VM from EC2 if you imported into EC2 originally. I have also found information that says you can only import into EC2 if the machine was originally exported from EC2.

My question is, is it possible to export a VM that was built on EC2, and somehow get it locally. I have read that you have to back it up to an S3 Bucket, and then download it, but Amazon's documentation says that you can only export it from there if it was originally imported.

Here are the links on serverfault that I found this question asked, but not answered.

Copy an Amazon EC2 Instance to use locally

Archiving Amazon AWS instances

trueCamelType
  • 1,016
  • 5
  • 19
  • 41
  • Have you tried doing a snapshot of the volume and copying it to an S3 bucket? – Craig Dec 01 '14 at 23:28
  • 2
    The idea is that your provisioning can reproduce the VM layout and configuration, and your image does not actually contain any persistent data, so why would you need to? Just provision locally... That's the theory at least ;) – HBruijn Dec 01 '14 at 23:37
  • This is where a configuration management system like Ansible works. Provision the same base OS (I like Ubuntu for this) on local dev and production and use Ansible to make a reproducible recipe for building the server from there. – ceejayoz Dec 02 '14 at 00:42
  • Taking a snapshot of the volume and copying to an S3 bucket is the recommended method, but Amazons docs say that you can't export the image unless it was imported there first. However, their documentation also says that you can't Import it unless it was originally exported from ec2. So according to Amazon's docs, you can't actually import or export.....I'm sure it's a typo, but I was trying to find out if anyone has successfully completed this action. – trueCamelType Dec 02 '14 at 14:12
  • @HBruijn I'm not sure I followed what you are saying. Did you mean I should just use a config. management tool like ceejayoz recommended, or were you saying something else? – trueCamelType Dec 02 '14 at 14:14
  • @Slimmons: I was on mobile and therefore a bit terse. In short : Yes. One of the key concepts in "cloud architecture" is IMHO that there should be no manual configuration actions, you automate as much as possible, making deployments repeatable. Carefully hand crafted templates are somewhat counter to that, you run the risks of [creating new pets](http://www.theregister.co.uk/2013/03/18/servers_pets_or_cattle_cern/) instead of keeping cattle. Doing cloud correctly also means that you're not bound to a single region (or even a single IaaS vendor) which is AFAIK a risk with using templates. – HBruijn Dec 02 '14 at 14:30
  • Thanks, I guess instead of depending on AWS EC2 to easily provide a backup, it's time for me to use Salt or something like it to create a repeatable deployment. Thanks – trueCamelType Dec 02 '14 at 14:47
  • I'm not going to write an answer, since the question still hasn't really been answered. If anybody knows if an AWS EC2 instance that was created there can be exported to a local machine, please type it in the answer section so I can approve it. – trueCamelType Dec 02 '14 at 14:49
  • Turns out I'm a little late to the party but: https://blog.filippo.io/converting-a-partition-image-to-a-bootable-disk-image/ – Steampunkery Feb 10 '18 at 03:33

3 Answers3

1

Yes, I was looking too for the answer, and recently I found that Amazon ec2 cannot tolerate importing instances created first time with ec2 hyper-visor.

What you can do is migrate the content of the VM to another placement, a reserved instance more cheaper for example, by creating a snapshot of an ebs boot partition in order to recreate the same vm. Preferably you would migrate within the same availability zone, so it's more cost effective. But migration outside the Amazon regions is impossible.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
1

if you could export an aws instance / image to openstack, for instance, bezos would be losing money..... the whole concept of the cloud is that instances are ephemeral and conf mgmt (puppet, salt, etc) is what makes them do what they do. data volumes are a different however, and that is obviously possible.

to actually boot an aws instance on your local hardware would be difficult. try snapshoting instance root drive, then mounting snapshot'd volume onto a newly lauched image, and then dd it to file and rsync to your local machine. then the fun begins.... you might be able to have it boot locally but probably impossible... never tried that as its not really fruitful

nandoP
  • 2,001
  • 14
  • 15
1

If you are migrating Windows Server and could log in the VM, using Disk2VHD command would be much easier way. I migrate several EC2 VMs to Azure, and believe you can migrate to a local Hyper-V server as well. https://tombwu.wordpress.com/2015/07/10/migrate-windows-server-from-aws-ec2-to-azure/

user298661
  • 11
  • 1