How to Setup Autonamic Backups on EC2
The tiendabonsai.net website is running on EC2 using an EBS volume to store all website files.
Why do I need backups on a Wordpress website
On a Wordpress website is kind of easy that somehow you mess up with some plugin or automatic update that could bring down the entire website pretty fast. To recover from these kind of situations a daily backup it’s great since allows you to rollback any change to the previous day state.
How to setup automatic backups step by step
Here the step to create a daily backup with a retention of the last 7 days:
- Got to AWS EC2 console
- Enter in Elastic Block Store > Lifecycle Manager
- Click to Create Lifecycle Policy
- Select the following options:
- Policy type:
EBS snapshot policy
- Select resource type:
- Description: Set a meaningful name
- Policy Tags: Set a tag if you want to keep track of AWS resources. In my case -> Name: tiendabonsai.net
- IAM Role: You can choose one or create a new default one
- Schedule name: Set a meaningful name for the schedule
- Starting at: Select a time where your site has low traffic
- Retention type:
- Copy tags from source: Check
- Click to Create Policy
After a day you’ll see that some snapshots start appearing on Elastic Block Store > Snapshots section. If you want to recover one just spin up a new instance and change your Route53 setup to point to the new instance.