Create Amazon RDS instance from snapshot - amazon-web-services

I want to do something very simple, I want to take a snapshot of a RDS instance (OK!) , and restore it on another instance but with a different size (duh!).
If I restore the snapshot It doesn't allow me to choose the capacity of the new instance.
If I create a DB instance, I dont know how to "attach" the snapshot.

RDS is a bit different. If you want to reduce the size of the volume, you need to export and reimport your data. When working from a snapshot, you have to choose the same volume size.

Related

My AWS EC2 EBS backups: are they volume or instance backups?

I have created some EBS backups over the years, but I can't remember if they were volume or instance backups. Is there some way to tell by looking at one or more field(s) in the list, e.g., at https://ap-southeast-1.console.aws.amazon.com/ec2/v2/home?region=ap-southeast-1#Snapshots:sort=desc:startTime, or in the detailed "description" when I click on one of the snapshots? (the detailed description looking as in the snapshot below, for example) Unfortunately, there isn't a field that says "EBS backup type" that takes a value of "instance" or "volume". As indicated in this stackoverflow question, for example, both types are stored as "EBS Snapshots", so as I understand it then, both will appear mixed together in the same list of EBS snapshots.
Most of the previous questions, e.g., this stackoverflow question, or other pages I've found from searching, have been about the differences between volume and instance backups, and how one might choose one or the other. However, I'm not asking about that, but just if there is any way I can tell what type my previous backups are. Or do I just have to tag the type myself or put it as part of the description string?
UPDATE
From looking at the VolumeID of the snapshot (vol-0565abe0e54ad4adf in the image, for example), I'm guessing that if an existing ec2 instance is using that volume, then that particular snapshot was an instance snapshot? But it could also have been a volume snapshot of that volume?
UPDATE 2
It appears there is some confusion regarding what I'm referring to (from the answers and comments posted so far). I'm not using DLM, but the EC2 console (see image below, and "Snapshot" is the place I navigate to.
Then, when I click on "Create snapshot", I see the following, which shows the options of volume and instance (the first question). This may be a new option, as I don't remember seeing it before.
An EBS snapshot is a backup of a single EBS volume. The EBS snapshot contains all the data stored on the EBS volume at the time the EBS snapshot was created.
An AMI image is a backup of an entire EC2 instance. Associated with an AMI image are EBS snapshots. Those EBS snapshots are the backups of the individual EBS volumes attached to the EC2 instance at the time the AMI image was created.
To get Snapshots associated with still running Volumes, attempt to match their VolumeID with the VolumeID of still running Volumes. Output the SnapshotID of matches.
A snapshot is performed on a single volume, these will always be a backup of the individual volume rather than th complete ec2 instance.
To restore this snapshot, you would restore it to create a new EBS volume that could then be attached to an EC2 instance.
If however your instance is running a single volume you can go one step further. Instead of launching as an EBS volume you can instead create an AMI from the snapshot. This AMI can then be used to launch further instances using the base image taking from the snapshot.
I suspect you are using Data Lifecycle Manager (DLM), not exactly AWS Backup, because you are getting snapshots, AWS Backup work with vault, so you would not see snapshot.
If this is the case, DLM only work with volumes, so you only get backup of your volumes, not instances.
With AWS Backup you can have both, backup of your volumes and/or backup of your instances.
They will be contained inside a vault when backup happens, when necessary you will need to restore it from vault, which will gives you an AMI or a volumes, depending on which kind of backup you did.
Thanks for your update!
I got your point, the instance option there is just a helper to facilitate your life, imagine that you have an instance with 2 volumes and you want to create a snapshot of both volumes, in this case you could go to this screen and create one
snapshot each time (refering volume id on each time), or you can do it once refering the instance id and console will get both volumes for you and create both snapshots.
Doesn't matter which option you choose there, it will just create snapshot from volume, it will not do anything about your instance. If you want you can add a tag in your snapshot to refer to your instance, but it is just a meta-data.
So in your case you are just creating "backups" of your volumes!
If you lose your volume you can restore it, but if you lose your instance you will have to recreate your instance again (with all details) manually.
If you want to create a "backup" from your instance you need to create an image, which will give you and AMI, not a snapshot.
AMI will "backup" your instance details and will create a snapshot from all instance volumes (not ephemeral ones).

How can I create an AWS AMI from a running instance but remove costly data

I have an EC2 instance that houses an application and a database. The current instance is running in a production environment with a populated database. I would like to create an AMI of the instance to use as a template for firing up new production servers but with an empty database.
If I just create an AMI from the instance then I believe it will contain all of the data which will have cost implications due to the size on disk and is also a security risk as the AMI would contain customer data.
I thought that I could create an AMI from the instance, then launch a new instance based on that AMI, delete all of the data, create a new AMI based on the new instance, then delete the original AMI and new instance.
My specific questions are:
Will I be able to delete the first AMI if the second AMI was based on an instance created from it?
I understand that the charges for AMIs are incremental in nature. How does it work if a new AMI is created from an instance that is smaller then the AMI that that instance was created from?
Is there a better way of achieving my objective?
Thanks
Will I be able to delete the first AMI if the second AMI was based on an instance created from it?
Yes. You can delete (i.e. de-register) your AMI even if you have an instance running which uses it. But this is something you can easily check on your own. Just create a dummy instance and try creating AMI from it, launch new instance, creating new AMI and so on.
I understand that the charges for AMIs are incremental in nature. How does it work if a new AMI is created from an instance that is smaller then the AMI that that instance was created from?
It won't be smaller. You can't decrease the volume size when you launch an instance from your AMI. You can only increase it. Deletion of your db from the volume will have no effect on the volume size nor its price.
Is there a better way of achieving my objective?
Depends how you define "better". What you described I think is the most logical way.

When to use EBS Snapshot vs AMI Image

I am having trouble understanding when an EBS Snapshot vs an AMI Image would be optimal.
If for instance, I have an EC2 Instance that contains a LAMP stack, with data in the MySQL database, and some other basic files, would it be sufficient to back this up using an EBS Snapshot or do I need an AMI Image? I understand the AMI Image will also back up the Operating System. I am having trouble understanding whether it is necessary to back up the OS to ensure the MySQL data is backed up.
So take a snapshot if you only need the base volume taken as a backup. From this you can only create a new volume. This can also be used to migrate a volume from one AZ to another, or to move it to a different region.
Take an AMI for the following reasons:
Take a snapshot of the instance vs the volume, all volumes will have a snapshot taken.
To rollout in an auto scaling group as a prebaked image.
To duplicate a server
For your case (a MySQL data backup) a snapshot is enough as you’d restore this to a volume and attach to a new instance.

Doubts about recovering a .pem of an EC2 in AWS

We are working with an EC2 instance in Amazon Web Services but we have lost our .pem.
In order to create a new one, we are following this guidance:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#replacing-lost-key-pair
However, we are a bit worried because of this warning:
When you stop an instance, the data on any instance store volumes is
erased. Therefore, if you have any data on instance store volumes that
you want to keep, be sure to back it up to persistent storage.
We cannot access the instance, therefore we cannot really make a proper backup. Instead, we have make a snapshot of the volumes in Elastic Block Store.
We are wondering if this is enough and we can indeed stop the instance to proceed to the pair key recover or we need to do something else in order not to lose any data.
It depends on the type of instance.
If it's EBS backed you are probably safe to proceed as the volume will be reattached.
If it's instance store backed and you lost access to it you basically have lost what's on that machine.
By the sounds of it it's EBS backed. If it's instance store backed and you later created and attached an EBS volume and used that, you're going to be able to restore/reattach that volume just fine - but it's going to be to another machine.
Depending on how many instances we are talking about you should also be able to take an AMI Image of the running instance which will take snapshot of the EBS but also the exact state of the instance.
However if the instance's root device type is using a EBS backed store all the data should be safe so saving a snapshot and relaunching a new instance with the snapshot should have the data.
Good luck.

how to clone an Amazon EBS volume into another one of smaller size

I have two amazon ec2 instances, (1) using SLES and running my current site, and (2) a new one using Amazon Linux. I am simply trying to move my site from the SLES and then retire it.
I have a 100GB EBS volume attached to the SLES server of which only about 20GB is actually used. What's the best way to bring the data over to the new instance?
create a new EBS volume of about 30GB and attach to new instance, use unix cp?
create a new EBS volume of about 30GB and attach to new instance, temporarily also attach the 100GB original volume the new instance, use unix cp?
something smarter/simpler, such as create a snapshot(?) of the 100GB EBS volume, somehow? create a new 30GB EBS volume out of it, and then attach that to the new instance? The extra benefit will be that I won't have to take down my site
Thanks a lot
It is easy to increase the size of a target volume, but the only way you're going to be able to make it smaller is to create a blank volume of the size you want. Then, either mount the new one to the old instance and do a copy or detach the old volume and reattach it to the new and do a copy. Basically, of the options you listed, only the first and second ones would work. The reason making a snapshot won't work is because creating a snapshot from a volume makes the snapshot the same size as the volume it was created from. You would get an error trying to create a volume from snapshot that is smaller than the original.