Sub topic 9
Running on-demand backups
An on-demand backup starts a backup job right now, outside any schedule. Use it before a risky change such as a schema migration, an OS upgrade, or a deployment. It is also a good first test that your vault and service role work.
This chapter assumes you have created a vault named app-vault and have a service role such as AWSBackupDefaultServiceRole. It also assumes you can read the CLI output of a basic AWS command.
What an on-demand backup needs
An on-demand backup needs three inputs. They come from concepts you have already met.
- A vault, which receives the recovery point.
- A service role, which AWS Backup assumes to read the resource and write the backup.
- A resource ARN, which names the single resource to protect.
You can also set a lifecycle. If you leave it out, the recovery point has no expiry and stays until you delete it. That is the most common source of surprise storage cost.
Start a backup
This command backs up one EBS volume into app-vault and keeps it for 35 days.
aws backup start-backup-job \
--backup-vault-name app-vault \
--resource-arn arn:aws:ec2:us-east-1:123456789012:volume/vol-0123456789abcdef0 \
--iam-role-arn arn:aws:iam::123456789012:role/service-role/AWSBackupDefaultServiceRole \
--lifecycle DeleteAfterDays=35The response includes a BackupJobId, a CreationDate, and a RecoveryPointArn. Save the job ID. You use it to follow progress.
How the job runs
Check the state with the job ID.
aws backup describe-backup-job \
--backup-job-id <backup-job-id>Look at the State field. Wait for COMPLETED. If the state is FAILED, read StatusMessage. The usual causes are:
| Symptom | Likely cause |
|---|---|
| Access denied in `StatusMessage` | The service role lacks permission on the resource or the KMS key |
| Resource not found | The ARN is wrong, or it is in another Region |
| Job ends as expired | The job did not start or finish within its allowed window |
The CLI call uses the Region of your current profile. The resource and vault must be in that same Region.
Confirm the result
When the job completes, the recovery point appears in the vault. List the vault contents to see it.
aws backup list-recovery-points-by-backup-vault \
--backup-vault-name app-vaultCheck ResourceArn, Status, and CalculatedLifecycle. The next chapter covers recovery points in more detail.
Exercise
You run start-backup-job without --lifecycle for an RDS database. Six months later, the recovery point is still in the vault. Why, and how would you avoid it?
Show answer
Without a lifecycle, the recovery point has no expiry date, so AWS Backup never deletes it. Avoid this by passing --lifecycle DeleteAfterDays=N when you start the job.