Documentation survey

备份和还原

This chapter contains information on the files you need to back up. With the built-in backup and restore solution (mgradm backup) you create SUSE Manager backups. Information about restoring from your backups in the case of a system failure completes this chapter.

由于 SUSE Manager 依赖数据库及已安装的程序和配置,因此备份安装的所有组件至关重要。

建议定期备份 SUSE Manager 安装,以防止数据丢失并实现快速恢复。

无论您使用哪种备份方法,可用空间必须是当前安装使用的空间量的至少三倍。空间不足可能导致备份失败,因此请经常检查可用空间。

1. Disable old method with smdba

Skip this section if you installed SUSE Manager 5.0 from scratch.

With the advent of the built-in solution, the old method with the smdba backup tool is deprecated. If you migrated from an old system with smdba to the new solution, you must disable the old funtionality and remove the old backup archives.

Either disable smdba before migrating (recommended) or later on the migrated SUSE Manager 5.0 system.

Procedure: Disabling old method with installed smdba before migration

This procedure only works when smdba is still installed.

+

This will change archive_command in /var/lib/pgsql/data/postgresql.conf as follows:

archive_command = '/bin/true'

Now your old system is ready to be migrated to SUSE Manager 5.0.

Procedure: Disabling old method on SUSE Manager 5.0 after migration

Use this procedure after migration, when smdba is no longer available.

  1. On the container host, as root, edit /var/lib/containers/storage/volumes/var-pgsql/_data/postgresql.conf and set these options:

    archive_mode = off
    archive_command = '/bin/true'
  2. Restart the container:

    mgradm restart

2. 备份 SUSE Manager

要备份 SUSE Manager 安装,最全面的方法是使用 mgradm backup create 命令。这种方法不仅可以节省备份管理时间,还可以在发生故障时更快地重新安装和重新同步。不过,这种方法需要大量磁盘空间,并且可能要花费很长时间才能完成备份。

命令 mgradm backup create 可备份某个目录。这个目录可以是本地目录或挂载的远程存储空间。

命令 mgradm backup create 允许自定义备份内容。有关所有可用选项,请参见 mgradm backup create --help

2.1. SUSE Manager 的完整备份

SUSE Manager 的完整备份包含以下组件的备份:

  • SUSE Manager 卷

  • 数据库卷

  • podman 网络配置

  • podman 机密

  • SUSE Manager systemd 服务

  • SUSE Manager 容器映像

创建完整备份期间,SUSE Manager 服务会自动停止。

过程:使用 mgradm backup create 创建完整备份
  1. 在容器主机上,以 root 身份执行以下命令创建备份:

    mgradm backup create $path

    请将 $path 替换为备份位置的路径。

2.2. SUSE Manager 的部分备份

mgradm backup create 工具允许创建部分备份。您可以跳过个别卷或所有卷、跳过数据库备份和映像。

特别是,当跳过数据库备份时,系统会创建备份而不停止 SUSE Manager 服务,备份可以作为两阶段备份流程中的一个阶段运行。

部分备份无法保证备份/恢复的一致性。

过程:创建部分备份(跳过数据库备份)
  1. 在容器主机上,以 root 身份执行以下命令创建备份:

    mgradm backup create --skipdatabase $path

    请将 $path 替换为备份位置的路径。

过程:创建部分备份(跳过卷)
  1. 在容器主机上,以 root 身份执行以下命令创建备份:

    mgradm backup create --skipvolumes $volumes $path

    请将 $path 替换为备份位置的路径。

    请将 $volumes 替换为备份中要包含的某个卷或一系列以逗号分隔的卷名称。

    使用 all 可以跳过所有卷(数据库卷除外)。

2.3. 备份额外的卷

命令 mgradm backup 可使用 SUSE Manager 卷的内部列表。如果安装期间配置了其他卷,或有其他卷需要添加到备份中,则需使用 --extravolumes $volumes 指定这些卷。

过程:创建包含其他自定义卷的备份
  1. 在容器主机上,以 root 身份执行以下命令创建备份:

    mgradm backup create --extravolumes $volume $path

    请将 $path 替换为备份位置的路径。

    请将 $volumes 替换为备份中要包含的某个卷或一系列以逗号分隔的卷名称。

2.4. 执行手动数据库备份

过程:执行手动数据库备份
  1. 请为备份分配永久存储空间。

  2. 在 SUSE Manager 容器主机的命令提示符处,以 root 身份执行以下命令:

    mgradm backup create --skipvolumes all --skipconfig --skipimages $path

3. 从现有备份恢复 SUSE Manager

从现有备份恢复 SUSE Manager 时,系统将枚举卷、映像和配置的备份以进行恢复。与创建备份的场景不同,恢复操作不使用内部卷列表,而是自动检测备份中存在的所有卷或映像。

收集待恢复项目列表后,会执行存在性和完整性检查。存在性检查用于确保恢复备份时不会意外覆盖现有卷、映像或配置。完整性检查通过计算备份项目的校验和完成。

两项检查均通过后,才会执行实际的备份恢复操作。

恢复操作完成后,SUSE Manager 服务不会自动启动。

过程:从现有备份恢复
  1. 在容器主机上以 root 身份运行以下命令,重新部署 SUSE Manager 服务器:

    mgradm backup restore $path
    mgradm start

    请将 $path 替换为备份位置的路径。

验证备份操作用时可能会很长。如果可通过其他方法确保备份完整性,则可以使用 --skipverify 选项跳过验证。

如果出于某些原因需要跳过恢复备份中的某个卷,可以使用 --skipvolumes $volumes 选项。

3.1. 恢复备份后建议执行的步骤

过程:恢复 SUSE Manager 后建议执行的步骤
  1. 使用 SUSE Manager Web UI 或在容器中的命令提示符处使用 mgr-sync 工具重新同步您的 SUSE Manager 储存库。您可以选择重新注册产品,或跳过注册和 SSL 证书生成部分。

  2. 在容器主机上,检查是否需要还原 /var/lib/containers/storage/volumes/var-spacewalk/_data/packages/。如果 /var/lib/containers/storage/volumes/var-spacewalk/_data/packages/ 不在您的备份中,则需要还原它。如果源储存库可用,则您可以通过完整通道同步来还原 /var/lib/containers/storage/volumes/var-spacewalk/_data/packages/

    mgrctl exec -ti -- mgr-sync refresh --refresh-channels

Schedule the re-creation of search indexes next time the rhn-search service is started. This command produces only debug messages, it does not produce error messages. On the container host, enter:

+

mgrctl exec -ti -- rhn-search cleanindex