Velero备份kubernetes

Velero备份kubernetes

velero 备份kubernetes

velero 介绍

查看支持各个厂家的插件

https://velero.io/docs/v1.10/supported-providers/

安装

先按照velero 软件

velero install  --provider aws --plugins velero/velero-plugin-for-aws:v1.2.1 --bucket  ys-dev-k8s-bak-1307155645 \
--secret-file ./credentials-velero \
--use-restic \
--default-volumes-to-restic \
--backup-location-config \
region=ap-beijing,s3ForcePathStyle="true",s3Url=https://cos.ap-beijing.myqcloud.com

或者
velero install  --provider aws --plugins velero/velero-plugin-for-aws:v1.8.1 --use-volume-snapshots=false --bucket  ys-dev-k8s-bak-1307155645 --secret-file ./credentials-velero   --backup-location-config region=ap-beijing,s3ForcePathStyle="true",s3Url=https://cos.ap-beijing.myqcloud.com  --use-node-agent 


#配置文件说明
vim credentials-velero    ###是对象存储的认证文件
[default]
aws_access_key_id = XXXX
aws_secret_access_key = XXXX

安装完成查看

image-20220630001535580

指定命名空间备份

velero backup create dmp-dev-backup --include-namespaces dmp-dev
velero backup create dmp-dev-backup --include-namespaces dmp-dev
Backup request "dmp-dev-backup" submitted successfully.
Run `velero backup describe dmp-dev-backup` or `velero backup logs dmp-dev-backup` for more details.

# 查看备份的进度
velero backup describe dmp-dev-backup --details   

查看备份

image-20220630002001363

备份完毕

image-20220630005759633

查看备份是否有错误

velero backup logs dmp-test-backup | grep error

指定应用的备份

恢复

将备份存储位置临时更新为只读模式(可以防止在还原过程中,velero在备份存储位置中创建或删除备份对象)

kubectl patch backupstoragelocation default --namespace velero \
            --type merge \
            --patch '{"spec":{"accessMode":"ReadOnly"}}' \
backupstoragelocation.velero.io/default patched

执行恢复命令

velero restore create --from-backup  dmp-dev-backup
##会显示如下内容		
Restore request "dmp-dev-backup-20220630094836" submitted successfully.
Run `velero restore describe dmp-dev-backup-20220630094836` or `velero restore logs dmp-dev-backup-20220630094836` for more details.

查看恢复

velero restore get

#查看恢复进度
velero restore describe dmp-dev-backup-20220630094836  --details

image-20220630095112988

卸载velero

kubectl delete namespace/velero clusterrolebinding/velero
kubectl delete crds -l component=velero
comments powered by Disqus