I want to be able to back up my linux accadamy lab servers but they don't provide a way to to this.

I'm wondering if it's posible to clone my EC2 lab server from inside the EC2 to get round this?

  • Please explain why you need this
    – 030
    Dec 12 '19 at 11:35
  • In this instance Iv been working through seting up puppet on amozon linux 2 on the lab servers and I want to back up my instance as I previosly messed it up and had to start configering it from scratch. Im useing the lab servers to save setting up a DNS name on my personal acount for the server and each agent.
    – doug
    Dec 13 '19 at 0:05

Yes, it can be done.

You can either create an IAM instance role which allows the instance to use ec2 actions such as "create-image" or you can create an IAM user and create for this user access and secret keys and a policy which allows this user to create images in ec2 and then configure the access and secret keys locally on the server using the "aws configure" command.

Whatever method you choose from the above options, the next step would be from within the instance itself and assuming you have aws-cli installed in the instance, first run:

ec2-metadata -i to get the instance id.

and then run:

aws ec2 create-image --instance-id INSTANCEID --name NameOfImage --no-reboot --region REGION

And it will create an image of this instance in the region you provided without rebooting the instance.

The create-image command will create an image of the instance, also called AMI which then you can use to create new instances from.

  • Would I still need access to the linux academy aws account the lab servers are hosts on?
    – doug
    Dec 13 '19 at 0:15
  • Could I create a public AMI if im given the right permitions?
    – doug
    Dec 13 '19 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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