mirror of
https://github.com/rubenhensen/k8scd.git
synced 2026-09-17 02:12:55 +02:00
Velero Backup Testing Guide
This guide explains how to test your Velero backups using a temporary K3d cluster.
Prerequisites
Ensure you have the following tools installed on your local machine:
- Docker
- kubectl
- Helm
- K3d
- Velero CLI
Setup
- First, clone this repository to your local machine:
git clone https://github.com/yourusername/backup-testing.git
cd backup-testing
- Make the scripts executable:
chmod +x setup-credentials.sh test-velero-backup.sh validate-restore.sh
- Set up your MinIO credentials:
./setup-credentials.sh
This script will look for credentials in ~/.velero/credentials-velero or prompt you to create them.
Running a Backup Test
Execute the test script with appropriate parameters:
./test-velero-backup.sh \
--s3-access-key <ACCESS_KEY> \
--s3-secret-key <SECRET_KEY> \
--backup-name <BACKUP_NAME> \
--original-namespace mbgwp \
--test-namespace mbgwp
./test-velero-backup.sh \
--s3-access-key YOUR_ACCESS_KEY \
--s3-secret-key YOUR_SECRET_KEY \
--original-namespace immich
This will:
- Create a temporary K3d cluster
- Install Longhorn for storage
- Install Velero configured to access your MinIO backup location
- List available backups
- Allow you to test restoring a specific backup
To restore a specific backup, run:
./test-velero-backup.sh \
--s3-access-key YOUR_ACCESS_KEY \
--s3-secret-key YOUR_SECRET_KEY \
--original-namespace immich \
--backup-name specific-backup-name
Testing Specific Applications
Immich
For testing Immich backups:
./test-velero-backup.sh \
--s3-access-key YOUR_ACCESS_KEY \
--s3-secret-key YOUR_SECRET_KEY \
--original-namespace immich \
--test-namespace immich-test
NextCloud
For testing NextCloud backups:
./test-velero-backup.sh \
--s3-access-key YOUR_ACCESS_KEY \
--s3-secret-key YOUR_SECRET_KEY \
--original-namespace nextcloud \
--test-namespace nextcloud-test
Testing with Volume Snapshots
To test CSI volume snapshot backups:
./test-velero-backup.sh \
--s3-access-key YOUR_ACCESS_KEY \
--s3-secret-key YOUR_SECRET_KEY \
--original-namespace immich \
--include-volume-snapshots
Customizing Validation
You can extend the validate-restore.sh script to perform application-specific validation checks:
- Edit the script to add application-specific checks
- Run your test with the modified validation:
./test-velero-backup.sh \
--s3-access-key YOUR_ACCESS_KEY \
--s3-secret-key YOUR_SECRET_KEY \
--original-namespace immich \
--backup-name your-backup \
--custom-validation-script ./your-custom-validation.sh
Troubleshooting
If you encounter issues:
-
Check the logs of the Velero pod:
kubectl logs -n velero deploy/velero -
Examine restore details:
velero restore describe RESTORE_NAME velero restore logs RESTORE_NAME -
Check cluster resources:
kubectl get pods -A kubectl get pvc -A