How do I protect my data against accidental EC2 instance termination?
Last updated: 2021-06-25
What are some options that AWS offers that can help me protect my data against accidental Amazon Elastic Compute Cloud (Amazon EC2) instance termination? How can I troubleshoot and collect more information about probable termination causes and behaviors?
To help protect against data loss caused by accidental termination of an Amazon EC2 instance, consider the following options when you configure EC2 infrastructure:
- Enable termination protection. Termination protection prevents an instance from accidental termination. By default, this option is disabled for EC2 instances. Enable this option to protect your instance from any unintentional termination. For more information, see Enable termination protection.
- Regularly back up your data. Back up your instance by doing one or more of the following:
Create an Amazon Machine Image (AMI). An AMI can capture the data on all the EBS volumes attached to an instance. You can use the AMI to launch a new instance.
Schedule regular Amazon Elastic Block Store (Amazon EBS) snapshots.
Use AWS Backup.
- Output data to another AWS service or source. Consider using one of the following services to store the workflows you run on your instance:
Amazon Simple Storage Service (Amazon S3)
Amazon Relational Database Service (Amazon RDS)
- Recreate your instance or restore data from a terminated instance. If you backed up your instances, then you can use the backup to restore the terminated instance. For more information, see How do I recreate a terminated EC2 instance?
- Troubleshoot termination behaviors to identify the causes of termination. Several issue can cause your instance to terminate immediately on start-up. Or, your instance configuration might lead to instance termination. For more information, see Troubleshoot instance termination (shutting down) and Why did Amazon EC2 terminate my instance?