Velero: Kubernetes Backup & Restore Solution

Β·

4 min read

Velero: Kubernetes Backup & Restore Solution

πŸ”Ή What is Velero?

Velero is an open-source tool for backing up, restoring, and migrating Kubernetes clusters and persistent volumes. It is widely used for disaster recovery, cluster migrations, and protecting Kubernetes workloads.


πŸ”Ή Key Features of Velero

βœ… Backup Kubernetes Clusters – Save snapshots of your cluster's resources and persistent data.
βœ… Restore Workloads – Recover applications and data after failures or accidental deletions.
βœ… Migrate Applications – Move workloads from one cluster to another.
βœ… Disaster Recovery – Protect against data loss, hardware failures, or cloud outages.
βœ… Schedule Backups – Automate regular backups for better resilience.


πŸ”Ή How Velero Works

Velero consists of:
1️⃣ A Server Component – Runs inside the cluster to manage backups and restores.
2️⃣ A CLI Tool – Used to interact with the Velero server.
3️⃣ A Backup Storage Location – Stores backups in object storage (S3, Azure Blob, Google Cloud Storage, MinIO, etc.).

It backs up:

  • Kubernetes objects (Deployments, Services, ConfigMaps, Secrets, etc.).

  • Persistent volumes (PVs) using snapshots (if configured).


πŸ”Ή Installation of Velero

1️⃣ Install Velero CLI

On macOS/Linux:

brew install velero

On Windows (via Chocolatey):

choco install velero

Alternatively, use the official install script:

curl -L -o /tmp/velero.tar.gz https://github.com/vmware-tanzu/velero/releases/download/v1.15.2/velero-v1.15.2-linux-arm64.tar.gz 
tar -C /tmp -xvf /tmp/velero.tar.gz
mv /tmp/velero-v1.15.2-linux-arm64/velero /usr/local/bin/velero
chmod +x /usr/local/bin/velero

velero --help

Verify installation:

velero version

πŸ”ΉDeploy some stuff

kind create cluster --name velero --image kindest/node:v1.19.1

docker run -it --rm -v ${HOME}:/root/ -v ${PWD}:/work -w /work --net host alpine sh

# install curl & kubectl
apk add --no-cache curl nano
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
export KUBE_EDITOR="nano"

#test cluster access:
/work # kubectl get nodes
NAME                    STATUS   ROLES    AGE   VERSION
velero-control-plane   Ready    master   26m   v1.18.4


kubectl apply -f kubernetes/configmaps/configmap.yaml
kubectl apply -f kubernetes/secrets/secret.yaml
kubectl apply -f kubernetes/deployments/deployment.yaml
kubectl apply -f kubernetes/services/service.yaml

kubectl get all

πŸ”Ή Setting Up Velero for AWS (Example)

2️⃣ Configure Backup Storage (AWS S3 Example)


cat > /tmp/credentials-velero <<EOF
[default]
aws_access_key_id=$AWS_ACCESS_ID
aws_secret_access_key=$AWS_ACCESS_KEY
EOF

velero install \
    --provider aws \
    --plugins velero/velero-plugin-for-aws:v1.1.0 \
    --bucket $BUCKET \
    --backup-location-config region=$REGION \
    --snapshot-location-config region=$REGION \
    --secret-file /tmp/credentials-velero

kubectl -n velero get pods
kubectl logs deployment/velero -n velero
  • Replace aws with gcp, azure, or minio for other providers.

πŸ”Ή Basic Operations

3️⃣ Backup a Namespace

velero backup create default-namespace-backup --include-namespaces default

# describe
velero backup describe default-namespace-backup

# logs
velero backup logs default-namespace-backup

# list 
velero backup get

4️⃣ Restore from Backup

# delete all resources

kubectl delete -f kubernetes/configmaps/configmap.yaml
kubectl delete -f kubernetes/secrets/secret.yaml
kubectl delete -f kubernetes/deployments/deployment.yaml
kubectl delete -f kubernetes/services/service.yaml

velero restore create default-namespace-backup --from-backup default-namespace-backup

# describe
velero restore describe default-namespace-backup

# logs 
velero restore logs default-namespace-backup

# monitor restore
velero restore get

# see items restored
kubectl get all

5️⃣ Schedule Automatic Backups

velero schedule create daily-backup --schedule="0 2 * * *"
  • Runs a backup daily at 2 AM.

6️⃣ Migrate Workloads to Another Cluster

  1. Take a backup from source cluster

     velero backup create cluster-backup
    
  2. Transfer the backup (if using MinIO or external storage).

  3. Restore in the destination cluster

     velero restore create --from-backup cluster-backup
    

πŸ”Ή Velero Use Cases

βœ… Disaster Recovery – Restore your cluster after failures.
βœ… Cluster Migration – Move workloads between Kubernetes clusters.
βœ… Data Protection – Schedule backups to avoid accidental data loss.
βœ… Rolling Back Changes – Restore previous application states.


πŸ”Ή Comparison: Velero vs Kasten K10 vs Stash

FeatureVeleroKasten K10Stash
Backup Kubernetes Objectsβœ… Yesβœ… Yesβœ… Yes
Backup Persistent Volumesβœ… Yesβœ… Yesβœ… Yes
Multi-Cloud Supportβœ… Yesβœ… Yesβœ… Yes
Data Encryption❌ Noβœ… Yesβœ… Yes
UI Dashboard❌ No (CLI only)βœ… Yes❌ No
Open Sourceβœ… Yes❌ No (Commercial)βœ… Yes

πŸ”Ή Conclusion

Velero is a powerful, open-source backup and restore solution for Kubernetes. It provides simple, CLI-based backup management and supports multi-cloud storage solutions.

Β