Reputation: 13
How can I automate EC2 instance snapshots every X time? By snapshot, I mean an image of all data and state and configuration of the virtual machine, so I can recover it quickly. Is there an AWS service for this purpose? What's the best way?
My EC2 instance type is m5.2xlarge
Upvotes: 0
Views: 3685
Reputation: 89
AWS has an service called Lifecycle Manager in EC2 dashboard. With the help of it, you can automate the backup procedure of the EBS volumes.
You can define backup and retention schedules for EBS snapshots by creating lifecycle policies based on tags defined for volumes.
With this feature, you no longer have to rely on custom scripts to create and manage your backups.
This feature is now available in the US East (N. Virginia), US West (Oregon), and Europe (Ireland) AWS regions at no additional cost.
Upvotes: 1
Reputation: 270294
You mention "all data and state and configuration of the virtual machine". This really consists of two parts:
Configuration of virtual machine
Backups normally only consist of the contents of the disks. The configuration of the virtual machine is specified when a replacement machine is launched, including:
It is not possible to "back-up" these settings, but you could create a CloudFormation template that launches an instance with matching settings. This can then become a repeatable, automated process.
Contents of the disks
The easiest way to backup the contents of the disks to allow the launch of an equivalent instance would be to create an Amazon Machine Image (AMI). The AMI contains a copy of all disks connected to the instance.
A new Amazon EC2 instance can then be launch from the AMI, and it will contain exactly the same data on the disks. (An AMI consists of Amazon EBS Snapshots, plus some metadata about the instance configuration. A new instance can be launched from an AMI, but not from an EBS Snapshot.)
If you wish to automate the regular creation of an AMI, you can use the Amazon Data Lifecycle Manager.
See: New – Lifecycle Management for Amazon EBS Snapshots | AWS News Blog
I also recommend that you test the backup by launching a new EC2 instance from the AMI.
Upvotes: 0
Reputation: 1532
Some of the options are;
OR
Upvotes: 1
Reputation: 14433
You may want to investigate a service called AWS Backup
. I have only read abou it, as it's relatively new, and I had imlemented a custom solution using a Lambda function before it became available,
If I were to do it again, I'd use AWS Backup
.
Upvotes: 1