Sub topic 6
Rules: schedules, start windows and completion windows
A backup rule tells AWS Backup when to start a backup, how long it may wait before starting, and how long it may run. This chapter assumes you have created a vault and written a basic backup plan. It also assumes you know cron syntax and what RPO means (the most data you can afford to lose, measured in time).
Where rules live
A backup plan holds one or more rules. Each rule is independent. It has its own schedule, its own target vault, and its own lifecycle. Resources assigned to the plan are backed up by every rule in it. A plan with two rules therefore produces two series of recovery points for each resource.
The fields covered here are:
| Field | Meaning | Default |
|---|---|---|
| `RuleName` | Name of the rule, unique within the plan | None (required) |
| `TargetBackupVaultName` | Vault that receives the recovery points | None (required) |
| `ScheduleExpression` | Cron expression for when the job is scheduled | Every day at 05:00 UTC when created in the console |
| `ScheduleExpressionTimezone` | IANA time zone used to read the cron expression | `Etc/UTC` |
| `StartWindowMinutes` | Time after the scheduled moment in which the job must start | 480 (8 hours) |
| `CompletionWindowMinutes` | Time after the job starts in which it must finish | 10080 (7 days) |
The minimum start window is 60 minutes.
Schedule expressions
AWS Backup uses a six-field cron expression: minutes, hours, day of month, month, day of week, year.
cron(0 5 ? * * *)This runs at 05:00 every day. One of day-of-month and day-of-week must be ?, as in other AWS cron expressions. Some other examples:
| Expression | Runs |
|---|---|
| `cron(0 */4 * * ? *)` | Every four hours, on the hour |
| `cron(30 23 ? * FRI *)` | Fridays at 23:30 |
| `cron(0 3 1 * ? *)` | The first day of each month at 03:00 |
| `cron(0 2 ? * MON-FRI *)` | Weekdays at 02:00 |
Backups can run no more often than once per hour. If your RPO is shorter than that, use continuous backup for the services that support it. That is covered in a later chapter.
Time zones
By default, the expression is read in UTC. This causes surprises when your organization thinks in local time. A job set for cron(0 2 * * ? *) runs at 02:00 UTC, which is the evening before in the Americas. Set ScheduleExpressionTimezone to a name such as America/New_York or Europe/Berlin so that the rule follows local time, including daylight saving changes.
The two windows
The schedule says when AWS Backup should begin considering a job. The two windows limit what happens after that.
- Start window. The clock starts at the scheduled time. If the job has not started when the window ends, AWS Backup does not run it, and the job ends in the
EXPIREDstate. - Completion window. The clock starts when the job actually starts. If the job has not finished when the window ends, AWS Backup stops it.
A job can fail to start on time because the resource is busy, an earlier job for the same resource is still running, or the service is throttling requests. The start window gives AWS Backup room to retry until things clear. A very short start window makes a missed backup more likely. A very long one can push a backup into your production peak.
The block above is only a placeholder for the real diagram. Here is the diagram in the required form:
Choosing window values
Pick the start window first. It should be long enough to absorb delays but short enough that a late backup does not land in a busy period. For a nightly backup at 05:00 UTC, a 60 to 120 minute start window is typical. The 480 minute default is generous. It is fine for non-critical data and too loose where you want predictable timing.
Then pick the completion window from observed run times. Look at how long past jobs took, and allow some headroom for growth. The first backup of a resource is a full copy for most services, so it takes much longer than later incremental ones. A completion window tuned to incremental runs can stop the first job. Raise the window for the first run, or run the first backup on demand, and tighten the rule later.
Keep the windows consistent with your schedule. If a job can run for 180 minutes and you schedule hourly, jobs for the same resource overlap, and the later ones may sit unstarted until their start window ends.
A plan with two rules
This plan keeps daily backups for 35 days and monthly backups for a year. Both use local time. Save it as plan.json.
{
"BackupPlanName": "daily-and-monthly",
"Rules": [
{
"RuleName": "DailyBackups",
"TargetBackupVaultName": "app-vault",
"ScheduleExpression": "cron(0 2 ? * * *)",
"ScheduleExpressionTimezone": "America/New_York",
"StartWindowMinutes": 60,
"CompletionWindowMinutes": 180,
"Lifecycle": {
"DeleteAfterDays": 35
}
},
{
"RuleName": "MonthlyBackups",
"TargetBackupVaultName": "app-vault",
"ScheduleExpression": "cron(0 3 1 * ? *)",
"ScheduleExpressionTimezone": "America/New_York",
"StartWindowMinutes": 120,
"CompletionWindowMinutes": 720,
"Lifecycle": {
"DeleteAfterDays": 365
}
}
]
}Create it and read it back:
aws backup create-backup-plan \
--backup-plan file://plan.json
aws backup get-backup-plan \
--backup-plan-id <backup-plan-id>The monthly rule gets a longer completion window because it is meant for the full set of data and may run alongside other jobs on the first of the month.
Changing a rule
You change rules with update-backup-plan, passing the complete new plan document. Each update creates a new plan version, identified by a version ID, and existing recovery points keep the lifecycle they were created with. A change to DeleteAfterDays does not rewrite earlier recovery points. It applies only to backups made after the update.
Checking what happened
List recent jobs and look at their states:
aws backup list-backup-jobs \
--by-backup-vault-name app-vault \
--by-state EXPIREDYou can also pass --by-state COMPLETED, RUNNING, FAILED or ABORTED. Each job record includes a status message that explains why the job did not finish.
Common errors
- Backups run at the "wrong" hour. The expression was read as UTC. Set
ScheduleExpressionTimezone. - Jobs show
EXPIRED. The job did not start inside the start window. Check for overlapping jobs, a stopped resource, or a role that lacks permissions, then widen the window if the delay is expected. - First backup stops partway. The completion window was sized for incremental runs. Increase it, or run the first backup on demand.
- Invalid cron expression. Both day-of-month and day-of-week were set to a value. One must be
?. - Edited rule did not change old backups. Rule changes apply only to new jobs.
Exercise
A rule uses cron(0 1 ? *) with the default time zone, StartWindowMinutes of 60 and CompletionWindowMinutes of 120. A database is locked by a maintenance task until 02:30 UTC, and then the backup could start. What happens to that night's job, and which single change would let it succeed?
Show answer
The scheduled time is 01:00 UTC, so the start window closes at 02:00 UTC. The resource is not available until 02:30, so the job does not start in time and ends as EXPIRED, leaving no recovery point. Raising StartWindowMinutes to at least 150 would let the job start at 02:30. Alternatively, move the schedule to after the maintenance task. The completion window starts only when the job starts, so it is not the cause.
Exercise
You want a backup at 23:00 on the last day you work each week, in London local time, and you want it to be skipped rather than start after 00:00. Which fields do you set?
Show answer
Set ScheduleExpression to something like cron(0 23 ? FRI ), set ScheduleExpressionTimezone to Europe/London, and set StartWindowMinutes to 60 (the minimum). A job that cannot start by 00:00 expires instead of running late.