Backup workflow
https://velero.io/docs/v1.14/how-velero-works/
- velero客户端调用Kubernetes API创建自定义资源并存储到etcd;
- Backup Controller通过Kubernetes API监听到新创建的backup对象,并验证;
- Backup Controller开始执行备份,通过Kubernetes API查询查询和收集需要备份的资源;
- Backup Controller调用Minio的S3接口上传备份数据。
install
https://github.com/vmware-tanzu/velero
https://velero.io/docs/v1.14/customize-installation/
1 | velero install \ |
credentials-file
credentials
[default]
aws_access_key_id=minioadmin
aws_secret_access_key=minioadmin
操作
备份
- 备份所有资源
1 | velero backup create <BACKUP_NAME> |
–include-namespaces 备份指定的命名空间
–include-resources 备份指定的资源,常用的有deployment,pods,services,secrets,configmaps
–exclude-namespace 排除命名空间
–exclude-resources 排除资源
–ttl 备份过期时间,默认为720h,即30天
- 查看备份列表
1 | velero get backups |
- 查看备份任务详情/进度
1 | velero backup describe <BACKUP_NAME> --detail |
还原
- 还原所有资源
1 | velero restore create --from-backup <BACKUP_NAME> |
–include-namespaces 备份指定的命名空间
–include-resources 备份指定的资源,常用的有deployment,pods,services,secrets,configmaps
–exclude-namespace 排除命名空间
–exclude-resources 排除资源
- 查看还原列表
1 | velero get restores |
- 查看还原详情/进度
1 | velero restore describe <RESTORE_NAME> --detail |
定时备份
- 可以设置定时备份任务
1 | velero schedule create <SCHEDULE_NAME> --schedule="0 1 * * *" --include-namespaces <NAMESPACES> --ttl 240 |
示例
1 | velero schedule create daily-backup --schedule="0 1 * * *" --include-namespaces argocd,blackbox,chaosblade --ttl 240 |
- 查看定时任务
1 | velero get schedules |
迁移
https://velero.io/docs/v1.14/migration-case/
- 排除kube-system命名空间的资源
- 如果storageClass的名称发生变更,需要进行映射
1 | kubectl apply -f velero-sc.yaml |
velero-sc.yaml
velero-sc.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: change-storage-class-config
namespace: velero
labels:
velero.io/plugin-config: ""
velero.io/change-storage-class: RestoreItemAction
data:
cfs-v4: <target-sc>