Blog & Press Releases
Kubernetes Backup & DR AWS

Velero: Backup & Disaster Recovery for Kubernetes

BootLabs Engineering October 2022 2 min read
Backing up a Kubernetes cluster with Velero

Velero is an open-source tool for safely backing up and restoring Kubernetes clusters — and recovering them after disaster. On AWS, Velero stores cluster backups in an S3 bucket and, optionally, snapshots your persistent volumes to disk. This is a quick tour of installing it, taking backups, restoring, and scheduling.

What Velero Does

  • Back up an entire cluster, or a single namespace, to object storage (an S3 bucket on AWS).
  • Restore that state — for example after a cluster is destroyed, a deployment fails, or a bad release needs rolling back.
  • Snapshot persistent volumes to disk, so stateful workloads are recoverable too.
  • Schedule recurring backups automatically on a cron interval.

Installation

Velero can be installed into the cluster (via its CLI or a Helm chart) in a velero namespace. Once installed, confirm the components are running:

kubectl get all -n velero

Next, establish the connection between the cluster and the S3 bucket (and disk, if you need volume backups). This requires an AWS credentials file. The velero install command wires it all together:

velero install
velero install \
  --provider aws \
  --image velero/velero:v1.8.0 \
  --plugins velero/velero-plugin-for-aws:v1.4.0 \
  --bucket <bucket_name> \
  --secret-file <path_to_credentials_file> \
  --use-volume-snapshots=false \
  --backup-location-config region=<bucket_region>
Backing up volumes?

Set --use-volume-snapshots=true if you need to snapshot persistent volumes as well as cluster objects. Leave it false to back up Kubernetes resources only.

Creating a Backup

Back up the whole cluster — or scope it to a single namespace with -n:

# back up the whole cluster
velero backup create t2

# back up a single namespace
velero backup create t2 -n <namespace>

These backups live in the S3 bucket and are available to restore from if the cluster is destroyed, a deployment fails, or a release introduces a bug.

Restoring from a Backup

Provided the connection between EKS and the S3 bucket is established, restoring is a single command referencing an existing backup:

velero restore create <restore_name> --from-backup <backup_name>

Automating Backups with a Schedule

Velero can run backups automatically on a schedule. A label selector scopes which resources the scheduled backup covers, and the interval can be expressed in minutes, days, or months:

velero schedule create
velero schedule create <schedule_name> \
  --schedule="<cron_expression>" \
  --selector app=<selector_name>

The --schedule flag takes a standard cron expression made up of five fields:

FieldMeaningRange
1Minute0–59
2Hour0–23
3Day of month1–31
4Month1–12
5Day of week0–6 (Sun–Sat)

For example, --schedule="0 2 * * *" runs a backup every day at 2:00 AM, while --schedule="@every 6h" runs one every six hours.

In short

Install Velero, point it at an S3 bucket, and you have on-demand cluster and namespace backups, one-command restores, and scheduled automated backups — a solid backup and disaster-recovery baseline for any EKS cluster.

BootLabs designs resilient, well-backed-up Kubernetes platforms for enterprises on AWS and beyond. If you're building out backup and disaster-recovery for your clusters, our platform team can help.

Make your Kubernetes clusters resilient.

Talk to our platform engineering team — we design backup, disaster-recovery, and high-availability strategies for production Kubernetes.