Velero Backups
Kubernetes Cluster: Velero Backups
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.
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.
2Create a backup bucket
Open the MinIO administration panel and create a bucket for Velero backups, for example velero.
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.
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
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}
Deploy Velero
Deploy Velero after replacing the storage-specific placeholders in the installation command.
{bucket}— S3 bucket name, for examplevelero.{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
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
Verify the application, persistent-volume claim, and persistent volume:
kubectl get pods,pvc,pv -n test-nginx
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
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
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
Check the S3-compatible bucket and verify that Velero and volume-backup data have been created.
Also verify the backup through the Velero CLI:
velero get backups
Test Restore
To test disaster recovery properly, remove the test namespace and the sample data before restoring the backup.
kubectl delete ns test-nginx
Remove the associated sample data from Shared Storage as well.
Restore the application from the Velero backup:
velero restore create --from-backup test-nginx-b4
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}"
| Position | Period | Accepted Values |
|---|---|---|
| 1 | Minute | 0-59, * |
| 2 | Hour | 0-23, * |
| 3 | Day of Month | 1-31, * |
| 4 | Month | 1-12, * |
| 5 | Day of Week | 0-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
