Velero Backups

Kubernetes Cluster: Velero Backups

Velero is an open-source Kubernetes backup and restore tool used for disaster recovery, migration, and persistent-volume protection. It can create manual or scheduled backups in external S3-compatible storage and restore either entire clusters or selected Kubernetes resources.
Backup & Recovery Back up a complete Kubernetes cluster or selected namespaces, resources, and persistent-volume data.
Cluster Migration Copy resources to another Kubernetes cluster or create development and test environments based on production data.

Prepare S3-Compatible Storage

Velero stores backups in external S3-compatible object storage. Suitable options include AWS S3, Virtuozzo Storage, or a MinIO cluster.

1Deploy object storage

The source example uses a MinIO Cluster deployed from Marketplace so the Kubernetes cluster and backup storage can remain on the same platform.

MinIO cluster installation
Example MinIO Cluster installation for Velero backup storage.

After MinIO installation, save the admin URL, access key, and secret key. These credentials are also sent by email and are required when Velero is configured.

MinIO cluster installed credentials
Keep the MinIO access credentials for the later Velero configuration.

2Create a backup bucket

Open the MinIO administration panel and create a bucket for Velero backups, for example velero.

Create MinIO bucket
Create a dedicated object-storage bucket for Kubernetes backups.

Install the Velero Client

Download the Linux AMD64 Velero release that is appropriate for the target Kubernetes environment. The source example uses Velero v1.8.1, but the exact version should be selected according to the current Velero/Kubernetes compatibility requirements.

Velero release version
The original example uses Velero v1.8.1.
The Velero CLI does not have to reside on a Kubernetes control-plane server. It can also be installed on another machine that has API access to the Kubernetes cluster.

For the source example, connect to the Kubernetes control plane through SSH and download/extract the Velero binary into /usr/local/sbin:

wget https://github.com/vmware-tanzu/velero/releases/download/v1.8.1/velero-v1.8.1-linux-amd64.tar.gz
tar -zxvf velero-v1.8.1-linux-amd64.tar.gz -C /usr/local/sbin --strip-components=1 velero-v1.8.1-linux-amd64/velero
Download Velero on Kubernetes control plane
Download and extract the Velero CLI on the Kubernetes control plane.

If the binary is uploaded using the file manager, make it executable:

chmod 755 /usr/local/sbin/velero

Configure S3 Credentials

Create /root/credentials-velero and add the S3-compatible storage access credentials.

[default]
aws_access_key_id = {accessKey}
aws_secret_access_key = {secretKey}
Velero S3 credentials
Store the S3 access and secret keys in the Velero credentials file.
Credential security: The credentials file contains object-storage secrets. Restrict access to the file and do not publish it in source repositories or shared documentation.

Deploy Velero

Deploy Velero after replacing the storage-specific placeholders in the installation command.

  • {bucket} — S3 bucket name, for example velero.
  • {s3Url} — HTTP endpoint of the S3-compatible storage.
  • {image} — Velero container image that matches the selected release.
velero install --provider aws \
--plugins velero/velero-plugin-for-aws:v1.4.1 \
--bucket {bucket} \
--secret-file ./credentials-velero \
--use-volume-snapshots=true \
--backup-location-config region=default,s3ForcePathStyle="true",s3Url={s3Url} \
--image {image} \
--snapshot-location-config region="default" \
--use-restic
Velero install command
Deploy Velero with the S3-compatible backup location and volume-data integration.
The original example uses AWS API emulation for S3-compatible storage and Restic because the NFS storage used in the cluster does not provide native volume snapshots.

Deploy a Test Application

The source demonstrates the backup process with a sample NGINX application that uses persistent storage.

wget https://www.virtuozzo.com/application-management-docs/kubernetes-velero-backups/test-instance.yaml
kubectl apply -f test-instance.yaml
Deploy Kubernetes test application
Deploy the sample application used to validate Velero backup and restore.

Verify the application, persistent-volume claim, and persistent volume:

kubectl get pods,pvc,pv -n test-nginx
Check Kubernetes test application
Confirm that the test pod and persistent storage resources are available.

Generate test data inside the mounted storage so the restore process can be validated later:

kubectl -n test-nginx exec -it nginx-test -- /bin/bash
dd if=/dev/urandom of=/usr/share/nginx/html/test-file3.txt count=512000 bs=1024
ls -laSh /usr/share/nginx/html/
exit
Generate test data in Kubernetes storage
Create sample data that can be checked after restoration.

Include Persistent-Volume Data

Annotate application pods so Velero knows which mounted NFS volume must have its data included in the backup.

kubectl -n test-nginx annotate pod/nginx-test backup.velero.io/backup-volumes=mystorage
Annotate Kubernetes pod for Velero volume backup
Annotate the pod with the volume name that must be backed up.
Important: Without the volume annotation, Velero can back up the PV and PVC definitions while the actual data stored on the NFS volume is not included.

Create and Verify a Backup

Create a backup for the test namespace and wait until the operation completes:

velero backup create test-nginx-b4 --include-namespaces test-nginx --wait
Create Velero backup
Create and wait for the namespace backup to finish.

Check the S3-compatible bucket and verify that Velero and volume-backup data have been created.

Velero backup data in MinIO
Velero backup objects stored in the MinIO bucket.

Also verify the backup through the Velero CLI:

velero get backups
Velero backup list
Confirm that the backup has completed successfully.

Test Restore

To test disaster recovery properly, remove the test namespace and the sample data before restoring the backup.

kubectl delete ns test-nginx
Delete Kubernetes namespace
Delete the sample namespace before testing restoration.

Remove the associated sample data from Shared Storage as well.

Delete Kubernetes test data from shared storage
Remove the test data from shared storage to verify that it is restored from backup.

Restore the application from the Velero backup:

velero restore create --from-backup test-nginx-b4
Restore Kubernetes application from Velero backup
Restore the Kubernetes resources and persistent data from the backup.
After the restore finishes, verify both Kubernetes resources and the previously generated persistent data.

Schedule Automatic Backups

Velero can automate backup creation with schedules. Cron schedules in the source workflow use the UTC timezone.

velero schedule create {scheduleName} --schedule="{schedule}"
PositionPeriodAccepted Values
1Minute0-59, *
2Hour0-23, *
3Day of Month1-31, *
4Month1-12, *
5Day of Week0-7, *

Example: create a backup every six hours using cron notation:

velero schedule create myschedule --schedule="0 */6 * * *"

The same interval can be expressed with the @every syntax:

velero schedule create myschedule --schedule="@every 6h"

Use the command help to review options for namespace selection, backup lifetime, and other scheduling parameters:

velero schedule create --help
Backup strategy: A backup is only useful when restoration has been tested. Periodically validate scheduled backups by restoring them into a safe test environment and confirming that both Kubernetes objects and persistent data are recoverable.

What’s next?