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 Multi-Linux Manager backups. Information about restoring from your backups in the case of a system failure completes this chapter.

Because SUSE Multi-Linux Manager relies on a database as well as the installed program and configurations, it is important to back up all components of your installation. Back up your SUSE Multi-Linux Manager installation regularly to prevent data loss and enable quick recovery.

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

1. Disable old method with smdba

Skip this section if you installed SUSE Multi-Linux Manager 5.1 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 Multi-Linux Manager 5.1 system.

Procedure: Disabling old method with installed smdba before migration

This procedure only works when smdba is still installed.

Commands are different on SUSE Manager 4.3 (non-containerized installation) or SUSE Manager 5.0 (containerized installation) present (so 5.0 or on 4.3 before migration):

+

SUSE Manager 4.3

On the command line, as root, execute:

smdba backup-hot --enable=off
SUSE Manager 5.0

On the command line of the container host, as root, execute:

mgrctl exec -- smdba backup-hot --enable=off

+

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 Multi-Linux Manager 5.1.

Procedure: Disabling old method on SUSE Multi-Linux Manager 5.1 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 Multi-Linux Manager

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

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

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

2.1. SUSE Multi-Linux Manager 的完整备份

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

  • SUSE Multi-Linux Manager 卷

  • 数据库卷

  • podman 网络配置

  • podman 机密

  • SUSE Multi-Linux Manager systemd 服务

  • SUSE Multi-Linux Manager 容器映像

The SUSE Multi-Linux Manager service is automatically stopped for the time it takes to create a full backup. The downtime can be significant. After backup is done, service is automatically restarted.

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

    mgradm backup create $path

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

2.2. SUSE Multi-Linux Manager 的部分备份

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

特别是,当跳过数据库备份时,系统会创建备份而不停止 SUSE Multi-Linux 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 Multi-Linux Manager 卷的内部列表。如果安装期间配置了其他卷,或有其他卷需要添加到备份中,则需使用 --extravolumes $volumes 指定这些卷。

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

    mgradm backup create --extravolumes $volume $path

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

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

2.4. 执行手动数据库备份

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

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

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

3. 从现有备份恢复 SUSE Multi-Linux Manager

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

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

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

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

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

    mgradm stop
    mgradm backup restore $path
    mgradm start

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

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

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

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

过程:恢复 SUSE Multi-Linux Manager 后建议执行的步骤
  1. 使用 SUSE Multi-Linux Manager Web UI 或在容器中的命令提示符处使用 mgr-sync 工具重新同步您的 SUSE Multi-Linux 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