Sub topic 13
Schedules and retention with TTL
This chapter assumes you can create a Velero backup, have Velero installed with a working backup storage location, and know basic cron syntax. A one-off backup protects you once. A schedule makes backups recurring, and a TTL (time to live) decides how long each backup is kept.
How a schedule works
A Velero Schedule is a custom resource that holds a cron expression and a backup template. When the time matches, Velero creates a regular Backup object from the template. The new backup is named after the schedule plus a timestamp, for example shop-daily-20261205020000.
velero schedule create shop-daily \
--schedule="0 2 * * *" \
--include-namespaces shop \
--ttl 168h0m0sThis creates a backup of the shop namespace every day at 02:00 and expires each backup after seven days. The cron fields are minute, hour, day of month, month and day of week. Velero evaluates the expression in the time zone of the Velero server Pod, which is usually UTC. Check this before you promise anyone a backup window.
Retention with TTL
Every backup has a TTL, set with --ttl. The default is 720h0m0s, which is 30 days. Velero records an expiration time in the backup's status. A garbage collection loop in the server checks for expired backups and deletes them, together with their files in object storage.
The value uses Go duration format, so it takes hours, minutes and seconds only. There is no d unit. Write seven days as 168h0m0s.
Choose a TTL from your recovery needs and your storage budget:
| Backup frequency | TTL | Backups kept | Use case |
|---|---|---|---|
| Hourly | `48h0m0s` | about 48 | Short recovery point for busy namespaces |
| Daily | `168h0m0s` | about 7 | Recovery from recent mistakes |
| Weekly | `720h0m0s` | about 4 | Longer history at a low cost |
You can set a TTL on a schedule and also on a single manual backup. A manual backup taken before a risky change can use a longer TTL than your scheduled ones.
Inspecting schedules
List schedules and the backups they produced:
velero schedule get
velero backup get
velero schedule describe shop-dailyThe describe output shows the last backup time and any validation errors. To stop new backups without losing existing ones, pause the schedule:
velero schedule pause shop-daily
velero schedule unpause shop-dailyCommon errors
- Schedule never fires. Check the cron expression and the schedule's phase. A phase of
FailedValidationmeans Velero rejected the template. - Backups disappear. This is the TTL working as designed. Raise
--ttlif you need a longer history. - Storage keeps growing. Backups without a TTL you can accept still use the 30 day default. Lower the TTL or reduce the frequency.
- Wrong backup hour. The cron expression runs in the Velero Pod's time zone, not yours.
- Deleting the schedule. Deleting a schedule stops new backups. Existing backups stay until their own TTL expires.
Exercise
You need a backup of the shop namespace every six hours, kept for three days. Write the command, and state roughly how many backups exist at any time.
Show answer
velero schedule create shop-6h --schedule="0 */6 * * *" --include-namespaces shop --ttl 72h0m0s. Four backups run per day for three days, so about 12 backups exist at once.