4.24. Restic 问题


在使用 Restic 备份应用程序时,您可能会遇到这些问题。

4.24.1. 启用了 root_squash 的 NFS 数据卷的 Restic 权限错误

Restic pod 日志显示以下出错信息: controller=pod-volume-backup error="fork/exec/usr/bin/restic: permission denied"。

原因

如果您的 NFS 数据卷启用了 root_squashRestic 映射到 nfsnobody,且没有创建备份的权限。

解决方案

您可以通过为 Restic 创建补充组并将组 ID 添加到 DataProtectionApplication 清单中来解决这个问题:

  1. 在 NFS 数据卷中为 Restic 创建补充组。
  2. 在 NFS 目录上设置 setgid 位,以便继承组所有权。
  3. spec.configuration.nodeAgent.supplementalGroups 参数和组 ID 添加到 DataProtectionApplication 清单中,如下例所示:

    apiVersion: oadp.openshift.io/v1alpha1
    kind: DataProtectionApplication
    # ...
    spec:
      configuration:
        nodeAgent:
          enable: true
          uploaderType: restic
          supplementalGroups:
          - <group_id> 1
    # ...
    1
    指定补充组 ID。
  4. 等待 Restic pod 重启,以便应用更改。

4.24.2. 在存储桶被强制后重新创建 Restic Backup CR

如果您为命名空间创建 Restic Backup CR,请清空对象存储的存储桶,然后为同一命名空间重新创建 Backup CR,重新创建的 Backup CR 会失败。

velero pod 日志显示以下错误消息:stderr=Fatal: unable to open config file: Stat: The specified key does not exist.\nIs there a repository at the following location?

原因

如果 Restic 目录从对象存储中删除,Velero 不会从 ResticRepository 清单重新创建或更新 Restic 存储库。如需更多信息,请参阅 Velero 问题 4421

解决方案

  • 运行以下命令,从命名空间中删除相关的 Restic 存储库:

    $ oc delete resticrepository openshift-adp <name_of_the_restic_repository>

    在以下错误日志中,mysql-persistent 是有问题的 Restic 存储库。存储库的名称会出现在其说明中。

     time="2021-12-29T18:29:14Z" level=info msg="1 errors
     encountered backup up item" backup=velero/backup65
     logSource="pkg/backup/backup.go:431" name=mysql-7d99fc949-qbkds
     time="2021-12-29T18:29:14Z" level=error msg="Error backing up item"
     backup=velero/backup65 error="pod volume backup failed: error running
     restic backup, stderr=Fatal: unable to open config file: Stat: The
     specified key does not exist.\nIs there a repository at the following
     location?\ns3:http://minio-minio.apps.mayap-oadp-
     veleo-1234.qe.devcluster.openshift.com/mayapvelerooadp2/velero1/
     restic/mysql-persistent\n: exit status 1" error.file="/remote-source/
     src/github.com/vmware-tanzu/velero/pkg/restic/backupper.go:184"
     error.function="github.com/vmware-tanzu/velero/
     pkg/restic.(*backupper).BackupPodVolumes"
     logSource="pkg/backup/backup.go:435" name=mysql-7d99fc949-qbkds

4.24.3. 因为更改了 PSA 策略,Restic 恢复部分在 OCP 4.14 上失败

OpenShift Container Platform 4.14 强制执行一个 pod 安全准入 (PSA) 策略,该策略可能会在 Restic 恢复过程中阻止 pod 的就绪度。 

如果创建 Pod 时找不到 SecurityContextConstraints (SCC) 资源,并且 pod 上的 PSA 策略没有设置为满足所需的标准,则 Pod 准入将被拒绝。 

造成这个问题的原因是 Velero 资源恢复的顺序。

错误示例

\"level=error\" in line#2273: time=\"2023-06-12T06:50:04Z\"
level=error msg=\"error restoring mysql-869f9f44f6-tp5lv: pods\\\
"mysql-869f9f44f6-tp5lv\\\" is forbidden: violates PodSecurity\\\
"restricted:v1.24\\\": privil eged (container \\\"mysql\\\
" must not set securityContext.privileged=true),
allowPrivilegeEscalation != false (containers \\\
"restic-wait\\\", \\\"mysql\\\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (containers \\\
"restic-wait\\\", \\\"mysql\\\" must set securityContext.capabilities.drop=[\\\"ALL\\\"]), seccompProfile (pod or containers \\\
"restic-wait\\\", \\\"mysql\\\" must set securityContext.seccompProfile.type to \\\
"RuntimeDefault\\\" or \\\"Localhost\\\")\" logSource=\"/remote-source/velero/app/pkg/restore/restore.go:1388\" restore=openshift-adp/todolist-backup-0780518c-08ed-11ee-805c-0a580a80e92c\n
velero container contains \"level=error\" in line#2447: time=\"2023-06-12T06:50:05Z\"
level=error msg=\"Namespace todolist-mariadb,
resource restore error: error restoring pods/todolist-mariadb/mysql-869f9f44f6-tp5lv: pods \\\
"mysql-869f9f44f6-tp5lv\\\" is forbidden: violates PodSecurity \\\"restricted:v1.24\\\": privileged (container \\\
"mysql\\\" must not set securityContext.privileged=true),
allowPrivilegeEscalation != false (containers \\\
"restic-wait\\\",\\\"mysql\\\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (containers \\\
"restic-wait\\\", \\\"mysql\\\" must set securityContext.capabilities.drop=[\\\"ALL\\\"]), seccompProfile (pod or containers \\\
"restic-wait\\\", \\\"mysql\\\" must set securityContext.seccompProfile.type to \\\
"RuntimeDefault\\\" or \\\"Localhost\\\")\"
logSource=\"/remote-source/velero/app/pkg/controller/restore_controller.go:510\"
restore=openshift-adp/todolist-backup-0780518c-08ed-11ee-805c-0a580a80e92c\n]",

解决方案

  1. 在 DPA 自定义资源 (CR) 中,检查或设置 Velero 服务器上的 restore-resource-priorities 字段,以确保在资源列表的 pod 之前列出 securitycontextconstraints

    $ oc get dpa -o yaml

    DPA CR 示例

    # ...
    configuration:
      restic:
        enable: true
      velero:
        args:
          restore-resource-priorities: 'securitycontextconstraints,customresourcedefinitions,namespaces,storageclasses,volumesnapshotclass.snapshot.storage.k8s.io,volumesnapshotcontents.snapshot.storage.k8s.io,volumesnapshots.snapshot.storage.k8s.io,datauploads.velero.io,persistentvolumes,persistentvolumeclaims,serviceaccounts,secrets,configmaps,limitranges,pods,replicasets.apps,clusterclasses.cluster.x-k8s.io,endpoints,services,-,clusterbootstraps.run.tanzu.vmware.com,clusters.cluster.x-k8s.io,clusterresourcesets.addons.cluster.x-k8s.io' 1
        defaultPlugins:
        - gcp
        - openshift

    1
    如果您有一个现有的恢复资源优先级列表,请确保将现有列表与完整列表合并。
  2. 确保应用程序 pod 的安全标准一致(如为部署修复 PodSecurity Admission 警告 中所述)以防止部署警告。如果应用程序与安全标准不一致,无论 SCC 是什么,都可能会出现错误。 
注意

这个解决方案是临时的,永久解决方案正在讨论中。 

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat, Inc.