Difference between revisions of "Velero Backup Kubernetes"

From UVOO Tech Wiki
Jump to navigation Jump to search
Line 4: Line 4:
 
- https://velero.io/docs/main/file-system-backup/
 
- 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 \
 +
  --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
 +
```
  
 
# Other
 
# Other

Revision as of 02:53, 17 June 2023

Top

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 \
   --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

Other

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://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