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?
DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. It only takes a minute to sign up.Sign up to join this community
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.