8.3. 执行备份
注意
以下示例 hello-world 应用没有附加的持久性卷。DPA 配置都将正常工作。
创建要备份的工作负载:
$ oc create namespace hello-world $ oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
公开路由:
$ oc expose service/hello-openshift -n hello-world
检查应用程序是否正常工作:
$ curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`
输出示例
Hello OpenShift!
备份工作负载:
$ cat << EOF | oc create -f - apiVersion: velero.io/v1 kind: Backup metadata: name: hello-world namespace: openshift-adp spec: includedNamespaces: - hello-world storageLocation: ${CLUSTER_NAME}-dpa-1 ttl: 720h0m0s EOF
等待备份完成:
$ watch "oc -n openshift-adp get backup hello-world -o json | jq .status"
输出示例
{ "completionTimestamp": "2022-09-07T22:20:44Z", "expiration": "2022-10-07T22:20:22Z", "formatVersion": "1.1.0", "phase": "Completed", "progress": { "itemsBackedUp": 58, "totalItems": 58 }, "startTimestamp": "2022-09-07T22:20:22Z", "version": 1 }
删除 demo 工作负载:
$ oc delete ns hello-world
从备份中恢复:
$ cat << EOF | oc create -f - apiVersion: velero.io/v1 kind: Restore metadata: name: hello-world namespace: openshift-adp spec: backupName: hello-world EOF
等待 Restore 完成:
$ watch "oc -n openshift-adp get restore hello-world -o json | jq .status"
输出示例
{ "completionTimestamp": "2022-09-07T22:25:47Z", "phase": "Completed", "progress": { "itemsRestored": 38, "totalItems": 38 }, "startTimestamp": "2022-09-07T22:25:28Z", "warnings": 9 }
检查工作负载是否已恢复:
$ oc -n hello-world get pods
输出示例
NAME READY STATUS RESTARTS AGE hello-openshift-9f885f7c6-kdjpj 1/1 Running 0 90s
$ curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`
输出示例
Hello OpenShift!
- 有关故障排除提示的信息,请参阅 OADP 团队的 故障排除文档
- 其他示例应用程序可以在 OADP 团队 的示例应用程序目录中找到