搜索

6.3. 执行备份

download PDF
注意

以下示例 hello-world 应用没有附加的持久性卷。DPA 配置都将正常工作。

  1. 创建要备份的工作负载:

    $ oc create namespace hello-world
    $ oc new-app -n hello-world --image=docker.io/openshift/hello-openshift
  2. 公开路由:

    $ oc expose service/hello-openshift -n hello-world
  3. 检查应用程序是否正常工作:

    $ curl `oc get route/hello-openshift -n hello-world -o jsonpath='{.spec.host}'`

    输出示例

    Hello OpenShift!

  4. 备份工作负载:

    $ 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
  5. 等待备份完成:

    $ 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
    }

  6. 删除 demo 工作负载:

    $ oc delete ns hello-world
  7. 从备份中恢复:

    $ cat << EOF | oc create -f -
    apiVersion: velero.io/v1
    kind: Restore
    metadata:
     name: hello-world
     namespace: openshift-adp
    spec:
     backupName: hello-world
    EOF
  8. 等待 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
    }

  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!

  10. 有关故障排除提示的信息,请参阅 OADP 团队的 故障排除文档
  11. 其他示例应用程序可以在 OADP 团队 的示例应用程序目录中找到
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.