πŸ“šBook Signing at KubeCon EU 2026Meet us at Booking.com HQ (Mon 18:30-21:00) & vCluster booth #521 (Tue 24 Mar, 12:30-1:30pm) β€” free book giveaway!RSVP Booking.com Event
Storage intermediate ⏱ 20 minutes K8s 1.28+

Velero Backup and Restore Kubernetes

Back up and restore Kubernetes applications with Velero. Scheduled backups, cross-cluster migration, selective restore, and disaster recovery workflows.

By Luca Berton β€’ β€’ πŸ“– 5 min read

πŸ’‘ Quick Answer: Install Velero with a cloud storage plugin, create Schedule resources for automated daily backups, and use Restore to recover applications. Velero backs up both Kubernetes resources (YAML) and persistent volume data (via snapshots or Restic/Kopia).

The Problem

etcd backups protect cluster state, but not application data on persistent volumes. If a namespace is accidentally deleted, you lose both the Kubernetes resources AND the PVC data. Velero backs up the complete application: manifests + volume data, enabling full application recovery.

The Solution

Install Velero

velero install \
  --provider aws \
  --bucket velero-backups \
  --secret-file ./credentials \
  --backup-location-config region=us-east-1 \
  --snapshot-location-config region=us-east-1 \
  --use-node-agent \
  --default-volumes-to-fs-backup

Scheduled Backup

apiVersion: velero.io/v1
kind: Schedule
metadata:
  name: daily-production
  namespace: velero
spec:
  schedule: "0 2 * * *"
  template:
    includedNamespaces:
      - production
      - databases
    storageLocation: default
    volumeSnapshotLocations:
      - default
    ttl: 720h
    defaultVolumesToFsBackup: true

Restore Application

# List available backups
velero backup get

# Restore entire namespace
velero restore create --from-backup daily-production-20260424

# Restore specific resources
velero restore create --from-backup daily-production-20260424 \
  --include-resources deployments,services,configmaps \
  --include-namespaces production

# Cross-cluster migration
velero restore create --from-backup daily-production-20260424 \
  --namespace-mappings production:staging

Backup Hooks (Pre/Post)

apiVersion: v1
kind: Pod
metadata:
  annotations:
    pre.hook.backup.velero.io/command: '["/bin/sh", "-c", "pg_dump -U postgres mydb > /backup/dump.sql"]'
    pre.hook.backup.velero.io/container: postgres
    post.hook.backup.velero.io/command: '["/bin/sh", "-c", "rm /backup/dump.sql"]'
graph LR
    SCHED[Schedule<br/>Daily 2 AM] --> BACKUP[Velero Backup<br/>Resources + Volumes]
    BACKUP --> S3[S3 Bucket<br/>30-day retention]
    
    S3 -->|Disaster| RESTORE[velero restore create]
    RESTORE --> RECOVERED[Namespace Recovered<br/>Deployments + PVCs βœ…]
    
    S3 -->|Migration| CROSS[Cross-cluster restore<br/>namespace mapping]

Common Issues

Backup stuck in β€˜InProgress’: Volume snapshots failing. Check: velero backup describe <name> --details. Common: CSI driver doesn’t support snapshots.

Restore creates PVCs but they’re Pending: StorageClass doesn’t exist in target cluster. Use --restore-volumes=false and recreate PVCs manually, or ensure matching StorageClasses.

Best Practices

  • Daily backups with 30-day TTL β€” good baseline for production
  • Pre-backup hooks for databases β€” pg_dump before snapshotting
  • Test restores monthly β€” untested backups are not backups
  • Cross-cluster migration β€” restore to a different cluster with namespace mapping
  • Exclude ephemeral namespaces β€” don’t waste storage backing up dev/test

Key Takeaways

  • Velero backs up Kubernetes resources AND persistent volume data
  • Scheduled backups with TTL for automated retention management
  • Pre/post-backup hooks enable application-consistent snapshots (database dumps)
  • Cross-cluster restore enables migration with namespace mapping
  • Test restores regularly β€” the backup is only as good as the restore
#velero #backup #restore #migration #disaster-recovery
Luca Berton
Written by Luca Berton

Principal Solutions Architect specializing in Kubernetes, AI/GPU infrastructure, and cloud-native platforms. Author of Kubernetes Recipes and creator of CopyPasteLearn courses.

Kubernetes Recipes book cover

Want More Kubernetes Recipes?

This recipe is from Kubernetes Recipes, our 750-page practical guide with hundreds of production-ready patterns.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens