Difference between revisions of "Velero Backup Kubernetes"
Jump to navigation
Jump to search
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | # Top | ||
+ | - https://stackoverflow.com/questions/75803242/velero-volume-snapshots-contain-no-data-when-restoring-a-backup | ||
+ | - https://velero.io/docs/main/contributions/minio/ | ||
+ | - https://velero.io/docs/main/file-system-backup/ | ||
+ | |||
+ | |||
+ | ## install-velero.sh | ||
+ | ``` | ||
+ | #!/bin/bash | ||
+ | set -eu | ||
+ | |||
+ | kubectl apply -f examples/minio/00-minio-deployment.yaml | ||
+ | sleep 10 | ||
+ | |||
+ | cat <<EOF> minio.credentials | ||
+ | [default] | ||
+ | aws_access_key_id=${MINIO_ACCESS_KEY} | ||
+ | aws_secret_access_key=${MINIO_SECRET_KEY} | ||
+ | EOF | ||
+ | |||
+ | velero install \ | ||
+ | --provider aws \ | ||
+ | --plugins velero/velero-plugin-for-aws:v1.5.5 \ | ||
+ | --bucket velero \ | ||
+ | --secret-file ./minio.credentials \ | ||
+ | --default-volumes-to-fs-backup \ | ||
+ | --use-node-agent \ | ||
+ | --use-volume-snapshots=false \ | ||
+ | --backup-location-config region=minio,s3ForcePathStyle="true",s3Url=http://minio.velero.svc:9000 | ||
+ | ``` | ||
+ | |||
+ | backup-restore.sh | ||
+ | ``` | ||
+ | set -ux | ||
+ | |||
+ | # kubectl delete ns nginx-example | ||
+ | # sleep 10 | ||
+ | kubectl apply -f examples/nginx-app/play.yaml | ||
+ | sleep 10 | ||
+ | |||
+ | rand=$(< /dev/urandom tr -dc a-z0-9 | head -c5) | ||
+ | kubectl -n nginx-example exec -it deploy/nginx-deployment -c nginx -- bash -c "echo foo was here > /var/log/nginx/foo.was.here.$rand.txt" | ||
+ | kubectl -n nginx-example exec -it deploy/nginx-deployment -c nginx -- ls -lhat /var/log/nginx | ||
+ | velero backup create "nginx-example-${rand}" --include-namespaces nginx-example --default-volumes-to-fs-backup --ttl 180h | ||
+ | echo done | ||
+ | |||
+ | echo delete; sleep 15 | ||
+ | kubectl delete namespace nginx-example | ||
+ | sleep 10 | ||
+ | kubectl get namespace/nginx-example || sleep 10 | ||
+ | echo restore; sleep 5 | ||
+ | velero restore create --from-backup "nginx-example-${rand}" | ||
+ | sleep 10 | ||
+ | kubectl -n nginx-example exec -it deploy/nginx-deployment -- ls -lhat /var/log/nginx | ||
+ | ``` | ||
+ | |||
+ | ## uninstall.sh | ||
+ | ``` | ||
+ | kubectl delete namespace/velero clusterrolebinding/velero | ||
+ | kubectl delete crds -l component=velero | ||
+ | kubectl delete ns nginx-example | ||
+ | ``` | ||
+ | |||
+ | # Other | ||
https://velero.io/docs/v1.6/examples/ | https://velero.io/docs/v1.6/examples/ | ||
+ | |||
+ | https://learn.microsoft.com/en-us/azure/aks/hybrid/backup-workload-cluster#install-velero-with-minio-storage | ||
https://learn.microsoft.com/en-us/azure/aks/hybrid/backup-workload-cluster#install-velero-with-azure-blob-storage | https://learn.microsoft.com/en-us/azure/aks/hybrid/backup-workload-cluster#install-velero-with-azure-blob-storage | ||
Line 6: | Line 72: | ||
https://github.com/vmware-tanzu/velero | https://github.com/vmware-tanzu/velero | ||
+ | |||
+ | https://velero.io/docs/main/file-system-backup/ | ||
+ | |||
+ | https://velero.io/docs/main/file-system-backup/#how-backup-and-restore-work |
Latest revision as of 03:12, 17 June 2023
Top
- https://stackoverflow.com/questions/75803242/velero-volume-snapshots-contain-no-data-when-restoring-a-backup
- https://velero.io/docs/main/contributions/minio/
- https://velero.io/docs/main/file-system-backup/
install-velero.sh
#!/bin/bash set -eu kubectl apply -f examples/minio/00-minio-deployment.yaml sleep 10 cat <<EOF> minio.credentials [default] aws_access_key_id=${MINIO_ACCESS_KEY} aws_secret_access_key=${MINIO_SECRET_KEY} EOF velero install \ --provider aws \ --plugins velero/velero-plugin-for-aws:v1.5.5 \ --bucket velero \ --secret-file ./minio.credentials \ --default-volumes-to-fs-backup \ --use-node-agent \ --use-volume-snapshots=false \ --backup-location-config region=minio,s3ForcePathStyle="true",s3Url=http://minio.velero.svc:9000
backup-restore.sh
set -ux # kubectl delete ns nginx-example # sleep 10 kubectl apply -f examples/nginx-app/play.yaml sleep 10 rand=$(< /dev/urandom tr -dc a-z0-9 | head -c5) kubectl -n nginx-example exec -it deploy/nginx-deployment -c nginx -- bash -c "echo foo was here > /var/log/nginx/foo.was.here.$rand.txt" kubectl -n nginx-example exec -it deploy/nginx-deployment -c nginx -- ls -lhat /var/log/nginx velero backup create "nginx-example-${rand}" --include-namespaces nginx-example --default-volumes-to-fs-backup --ttl 180h echo done echo delete; sleep 15 kubectl delete namespace nginx-example sleep 10 kubectl get namespace/nginx-example || sleep 10 echo restore; sleep 5 velero restore create --from-backup "nginx-example-${rand}" sleep 10 kubectl -n nginx-example exec -it deploy/nginx-deployment -- ls -lhat /var/log/nginx
uninstall.sh
kubectl delete namespace/velero clusterrolebinding/velero kubectl delete crds -l component=velero kubectl delete ns nginx-example
Other
https://velero.io/docs/v1.6/examples/
https://foxutech.medium.com/how-to-take-azure-kubernetes-backup-using-velero-3a841753a9f7
https://github.com/vmware-tanzu/velero
https://velero.io/docs/main/file-system-backup/
https://velero.io/docs/main/file-system-backup/#how-backup-and-restore-work