Operator 环境的备份和恢复


Red Hat Ansible Automation Platform 2.5

在 OpenShift Container Platform 中,使用备份和恢复 Ansible Automation Platform 来防止数据丢失

Red Hat Customer Content Services

摘要

本指南提供在 OpenShift Container Platform 上备份和恢复 Red Hat Ansible Automation Platform Operator 安装的步骤和参考信息。

前言

感谢您对 Red Hat Ansible Automation Platform 的关注。Ansible Automation Platform 是一个商业产品,它可以帮助团队通过增加控制、知识、协调基于 Ansible 的环境来更好地管理多阶的复杂部署环境。

使用本指南中的步骤创建备份资源,可用于在失败时恢复 Red Hat Ansible Automation Platform 部署。

对红帽文档提供反馈

如果您对本文档有任何改进建议,或发现错误,请通过 https://access.redhat.com 联系技术支持来创建一个请求。

为了防止意外的数据丢失和应用程序错误,对 Red Hat Ansible Automation Platform 部署执行定期备份至关重要。除了数据丢失的防止外,备份还允许您回退到不同的部署状态。

1.1. 关于备份和恢复

红帽建议在 Red Hat OpenShift Container Platform 环境中备份 Red Hat Ansible Automation Platform 部署,以防止数据丢失。

Red Hat Ansible Automation Platform 部署的备份资源包括:

  • Ansible Automation Platform 自定义资源对象的 spec 部分中的特定值自定义部署。
  • 备份 postgresql 数据库。
  • SECRET_KEYadmin_passwordbroadcast_websocket secret。
  • 数据库配置。
注意

确保备份资源的安全,因为它们可以包含敏感信息。

1.1.1. 备份建议

恢复数据丢失需要您定期计划并创建 Red Hat Ansible Automation Platform 部署的备份资源。红帽建议在以下情况下备份 Red Hat Ansible Automation Platform 部署:

  • 在升级 Red Hat Ansible Automation Platform 部署前。
  • 在升级 OpenShift 集群前。
  • 每周一次。如果您的环境被配置为自动升级,这尤其重要。

备份 Red Hat Ansible Automation Platform 部署涉及为部署的实例创建备份资源。使用以下步骤为您的 Red Hat Ansible Automation Platform 部署创建备份资源。我们建议在升级 Ansible Automation Platform Operator 前进行备份。如果您要将平台恢复到以前的状态,请定期进行备份。

2.1. 备份 Ansible Automation Platform 部署

定期备份 Ansible Automation Platform 部署对于防止意外数据丢失和应用程序错误至关重要。当您备份 Ansible Automation Platform 时,Ansible Automation Platform 会托管任何启用的组件(如自动化控制器、自动化中心和 Event-Driven Ansible),Operator 也会备份这些组件。

注意

Ansible Automation Platform Operator 会自动为您的 Ansible Automation Platform 备份创建一个 PersistentVolumeClaim (PVC)。您可以使用 backup_pvc spec 并指定 PVC 来使用您自己的预先创建 PVC。

先决条件

  • 您必须在 OpenShift 集群上进行身份验证。
  • 在集群中安装了 Ansible Automation Platform Operator。
  • 已使用 Ansible Automation Platform Operator 部署了一个 Ansible Automation Platform 实例。

流程

  1. 登录到 Red Hat OpenShift Container Platform。
  2. 进入到 OperatorsInstalled Operators
  3. 选择 Ansible Automation Platform Operator 部署。
  4. 前往您的 All Instances 选项卡,然后单击 Create New
  5. 从列表中选择 Ansible Automation Platform Backup

    注意

    在创建 Ansible Automation Platform Backup 资源时,它还会为启用的每个嵌套组件创建备份资源。

  6. Name 字段中输入备份的名称。
  7. Deployment name 字段中,输入正在备份的部署 Ansible Automation Platform 实例的名称。例如,如果您的 Ansible Automation Platform 部署必须备份,并且部署名称为 aap,在 Deployment name 字段中输入 'aap'。
  8. Create。这会导致 AnsibleAutomationPlatformBackup 资源类似如下:

    apiVersion: aap.ansible.com/v1alpha1
    kind: AnsibleAutomationPlatformBackup
    metadata:
      name: backup
      namespace: aap
    spec:
      no_log: true
      deployment_name: aap

    验证

    要验证备份是否成功,您可以:

  9. 登录到 Red Hat OpenShift Container Platform。
  10. 进入到 OperatorsInstalled Operators
  11. 选择 Ansible Automation Platform Operator 部署。
  12. 单击 All Instances

All Instances 页面显示主备份,以及每个组件的备份以及您在创建备份资源时指定的名称。以下实例的状态必须是 RunningSuccessful

  • AnsibleAutomationPlatformBackup
  • AutomationControllerBackup
  • EDABackup
  • AutomationHubBackup

如果您丢失了系统的信息或升级出现问题,您可以使用部署实例的备份资源。使用以下步骤恢复 Ansible Automation Platform 部署文件。

3.1. 恢复 Ansible Automation Platform 部署

当恢复 Ansible Automation Platform 时,Ansible Automation Platform 管理任何启用的组件(如自动化控制器、自动化中心和 Event-Driven Ansible)。

在以前的 Ansible Automation Platform Operator 版本中,需要为每个平台组件创建一个恢复对象。现在,您可以创建一个单个 AnsibleAutomationPlatformRestore 资源,它会创建和管理其他恢复对象:

  • AutomationControllerRestore
  • AutomationHubRestore
  • EDARestore

先决条件

  • 您必须使用 OpenShift 集群进行身份验证。
  • 在集群中安装了 Ansible Automation Platform Operator。
  • 集群中提供了 AnsibleAutomationPlatformBackups 部署。

流程

  1. 登录到 Red Hat OpenShift Container Platform。
  2. 进入到 OperatorsInstalled Operators
  3. 选择 Ansible Automation Platform Operator 部署。
  4. 前往您的 All Instances 选项卡,然后单击 Create New
  5. 从列表中选择 Ansible Automation Platform Restore
  6. 对于 Name,输入恢复部署的名称。
  7. 对于 New Ansible Automation Platform Name,请输入 Ansible Automation Platform 实例的新名称。
  8. 备份源 默认为 CR
  9. 对于 Backup name,请输入您在创建备份时选择的名称。
  10. Create

验证

您的备份开始在 AnsibleAutomationPlatformRestores 选项卡下恢复。

注意

在成功恢复所有资源前,恢复不会完成。根据数据库的大小,这可能需要一些时间。

要验证您的恢复是否成功,您可以:

  1. 进入 WorkloadsPods
  2. 确认所有 pod 都处于 RunningCompleted 状态。

3.2. 从 PVC 恢复 Ansible Automation Platform 部署

持久性卷声明(PVC)是一个存储卷,用于存储自动化中心和自动化控制器应用程序的数据。这些 PVC 独立于应用程序,即使应用程序被删除也是如此。您可以从 PVC 恢复数据,作为从 Ansible Automation Platform 备份中恢复的替代选择。

如需更多信息,请参阅在 OpenShift Container Platform 上安装 指南中的 查找和删除 PVC 部分。

先决条件

  • 您有一个包含备份的现有 PVC。
  • 您已在 Red Hat OpenShift Container Platform 上安装了 Ansible Automation Platform Operator。

流程

  1. 登录到 Red Hat OpenShift Container Platform。
  2. 进入到 OperatorsInstalled Operators
  3. 选择 Ansible Automation Platform Operator 部署。
  4. 前往您的 All Instances 选项卡,然后单击 Create New
  5. 从列表中选择 Ansible Automation Platform Restore
  6. 对于 Name,输入恢复部署的名称。
  7. 对于 New Ansible Automation Platform Name,请输入 Ansible Automation Platform 实例的新名称。
  8. 对于 Backup Source,请选择 PVC

    1. 备份 PVC: 输入 PVC 的名称。
    2. 备份目录:输入 PVC 中备份 目录的路径。
  9. 对于 Backup name,请输入您在创建备份时选择的名称。
  10. 在以下示例中,在 YAML 视图 粘贴下:

    ---
    apiVersion: aap.ansible.com/v1alpha1
    kind: AnsibleAutomationPlatformRestore
    metadata:
      name: aap
    spec:
      deployment_name: aap
      backup_source: PVC
      backup_pvc: aap-backup-claim
      backup_dir: '/backups/aap-openshift-backup-2025-06-23-18:28:29'
    
      controller:
        backup_source: PVC
        backup_pvc: aap-controller-backup-claim
        backup_dir: '/backups/tower-openshift-backup-2025-06-23-182910'
    
      hub:
        backup_source: PVC
        backup_pvc: aap-hub-backup-claim
        backup_dir: '/backups/openshift-backup-2025-06-23-182853'
        storage_type: file
    
      eda:
        backup_source: PVC
        backup_pvc: aap-eda-backup-claim
        backup_dir: '/backups/eda-openshift-backup-2025-06-23-18:29:11'
  11. Create

验证

您的备份在 AnsibleAutomationPlatformRestores 选项卡下恢复。

注意

在成功恢复所有资源前,恢复不会完成。根据数据库的大小,这可能需要一些时间。

  1. 进入 WorkloadsPods
  2. 确认所有 pod 都处于 RunningCompleted 状态。

您可以使用 Operator 在 Red Hat OpenShift Container Platform 上恢复外部数据库。使用以下步骤从外部数据库恢复。

重要

从外部数据库恢复会强制丢弃数据库,这会覆盖您现有的外部数据库。

先决条件

  • 您有一个外部数据库。
  • 您已在 OpenShift Container Platform 上安装了 Ansible Automation Platform Operator。

流程

  1. 登录到 Red Hat OpenShift Container Platform。
  2. 进入到 OperatorsInstalled Operators
  3. 选择 Ansible Automation Platform Operator 部署。
  4. 前往您的 All Instances 选项卡,然后单击 Create New
  5. 从列表中选择 Ansible Automation Platform Restore
  6. 对于 Name,输入恢复部署的名称。
  7. 对于 New Ansible Automation Platform Name,请输入 Ansible Automation Platform 实例的新名称。

    • 如果恢复到相同的名称 Ansible Automation Platform,则必须添加 force_drop_db: true 在恢复时丢弃数据库。
  8. 备份源 默认为 CR
  9. 对于 Backup name,请输入您在创建备份时选择的名称。在以下示例中,在 YAML 视图 粘贴下:

    ---
    apiVersion: aap.ansible.com/v1alpha1
    kind: AnsibleAutomationPlatformRestore
    metadata:
      name: aaprestore
    spec:
      deployment_name: aap
      backup_name: aapbackup
      controller:
        force_drop_db: true
  10. Create

验证

您的备份开始在 AnsibleAutomationPlatformRestores 选项卡下恢复。

注意

在成功恢复所有资源前,恢复不会完成。根据数据库的大小,这可能需要一些时间。

要验证您的恢复是否成功,您可以:

  1. 进入 WorkloadsPods
  2. 确认所有 pod 都处于 RunningCompleted 状态。

第 4 章 故障排除

使用这些信息诊断和解决备份和恢复过程中的问题。

为新 AutomationController 自定义资源指定的名称必须与现有部署不匹配,否则恢复过程将失败。

如果您的 AutomationController 客户资源与现有部署匹配,请执行以下步骤来解决这个问题。

流程

  1. 删除现有的 AutomationController 和关联的 postgres PVC:

    oc delete automationcontroller <YOUR_DEPLOYMENT_NAME> -n <YOUR_NAMESPACE>
    
    oc delete pvc postgres-13-<YOUR_DEPLOYMENT_NAME>-13-0 -n <YOUR_NAMESPACE>
  2. 使用带有相同 deployment_name 的 AutomationControllerRestore :

    oc apply -f restore.yaml

法律通告

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部