Sub topic 10
Creating and inspecting backups
This chapter assumes you have a working Velero install with a backup storage location, as set up in the previous chapter. It also assumes you are comfortable with kubectl, namespaces and labels. Here you create a backup, scope it, and read the results.
What a backup contains
A Velero backup is a tarball of Kubernetes object definitions, saved as JSON in your bucket. The velero CLI creates a Backup custom resource. The Velero server sees it, queries the API server for matching objects, and uploads the result with its metadata and logs. Velero reads objects through the API. It does not touch etcd.
Creating a backup
The command below backs up the shop namespace, including volume data through file system backup. It keeps the backup for 30 days.
velero backup create shop-backup \
--include-namespaces shop \
--default-volumes-to-fs-backup \
--ttl 720h0m0sThe --ttl flag sets the retention period. When it passes, Velero deletes the backup. Volume handling is covered in a later chapter. For now, note that --default-volumes-to-fs-backup makes the node agent copy volume contents.
Scoping a backup
Without filters, Velero backs up every namespace. Narrow the scope with these flags:
| Flag | Effect |
|---|---|
| `--include-namespaces` | Only the listed namespaces |
| `--exclude-namespaces` | Everything except the listed namespaces |
| `--selector` | Only objects matching a label selector |
| `--include-resources` | Only the listed resource types |
| `--exclude-resources` | Skip the listed resource types |
For example, velero backup create web-only --selector app=web captures only objects labeled app=web.
Inspecting a backup
Creating a backup returns immediately. The work happens in the background, so check the result.
velero backup describe shop-backup --detailsRead these parts of the output:
- Phase.
NewandInProgressare transient.Completedis what you want.PartiallyFailedmeans some items were skipped.Failedmeans no usable backup. - Errors and Warnings. Counts appear in the output. Read them even when the phase is
Completed. - Expiration. The date Velero will delete the backup.
- Resource List. Shown with
--details. It lists the objects that were saved. - Volume details. These show whether volume data was backed up.
To read the server's log for the backup, run velero backup logs shop-backup. Use velero backup get to list all backups and their phases.
Common errors
- Backup stays in
New. The Velero server is not running or cannot read the backup storage location. Checkvelero backup-location getand the server Pod logs. PartiallyFailedfrom volumes. The node agent may be missing. Reinstall with--use-node-agentor check that the node agent Pods are running.- Objects missing. A label selector or namespace filter was too narrow. Compare the resource list against what you expected.
- Backup deleted earlier than planned. The default TTL is 30 days. Set
--ttlexplicitly.
Exercise
You run velero backup create web-only --selector app=web and the phase becomes Completed. Which command shows exactly which objects were saved, and what flag adds the detail?
Show answer
Run velero backup describe web-only --details. The --details flag adds the resource list.
Exercise
A backup shows PartiallyFailed. Which two commands do you use first to find out why?
Show answer
velero backup describe <name> --details shows the errors and warnings. velero backup logs <name> shows the server's log for that backup.