Sub topic 5
Designing a backup plan
This chapter assumes you can use the AWS CLI, understand IAM roles, know how resource tagging works, and have a basic idea of RPO (how much data you can afford to lose) and RTO (how long you can afford to be down). You should already have a vault such as app-vault.
What a backup plan is
A backup plan is a policy document that says when to back up, where to store the backups, and how long to keep them. A plan does not name resources. It contains one or more rules. You attach resources to the plan separately, in a resource assignment.
Start from the recovery goal
Design the plan from your RPO. A daily rule means you can lose up to a day of data. If that is too much, you need a more frequent schedule or continuous backup, which a later chapter covers. Then decide how far back you may need to restore, and set retention to match.
Group workloads by recovery need, not by service. A production database and a scratch EC2 volume should usually sit in different plans, because they need different frequency and retention.
Write the plan file
This plan has one rule. It starts a backup daily at 05:00 UTC, allows 60 minutes for the job to start and 180 minutes to finish, and deletes recovery points after 35 days.
{
"BackupPlanName": "daily-35-day-retention",
"Rules": [
{
"RuleName": "DailyBackups",
"TargetBackupVaultName": "app-vault",
"ScheduleExpression": "cron(0 5 ? * * *)",
"StartWindowMinutes": 60,
"CompletionWindowMinutes": 180,
"Lifecycle": {
"DeleteAfterDays": 35
}
}
]
}Each field in the rule has a job:
| Field | Purpose |
|---|---|
| `RuleName` | Identifies the rule inside the plan. |
| `TargetBackupVaultName` | The vault that stores the recovery points. It must already exist. |
| `ScheduleExpression` | A cron expression, evaluated in UTC by default. |
| `StartWindowMinutes` | How long the job may wait to start before it is marked as expired. |
| `CompletionWindowMinutes` | How long the job may run after it starts before AWS Backup cancels it. |
| `Lifecycle` | When to move to cold storage and when to delete. |
Create the plan
Save the JSON as plan.json and run:
aws backup create-backup-plan \
--backup-plan file://plan.jsonThe response contains a BackupPlanId. You need it for the resource assignment in the next steps. Creating a plan does not back anything up until at least one resource is assigned to it.
Common design errors
- Windows too tight. If the start window is too short and the resource is busy, the job expires. If the completion window is too short for a large volume, the job is canceled. Size the completion window for your largest resource.
- Everything in one plan. A single plan forces one retention period on all data. Split plans by recovery need.
- Missing vault. A rule that names a vault that does not exist is rejected.
- Plan without assignments. The plan is valid but protects nothing.
Exercise
A plan has one rule with a 30-minute completion window. It protects a large volume that takes 2 hours to back up. What happens, and how do you fix it?
Show answer
AWS Backup cancels the job when the 30-minute completion window ends, so no recovery point is produced. Raise CompletionWindowMinutes above the longest expected backup time, for example to 240.