备份和还原
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 |
Either disable smdba before migrating (recommended) or later on the migrated SUSE Manager 5.0 system.
This procedure only works when smdba is still installed.
+
This will change
archive_commandin/var/lib/pgsql/data/postgresql.confas follows:archive_command = '/bin/true'
Now your old system is ready to be migrated to SUSE Manager 5.0.
Use this procedure after migration, when smdba is no longer available.
On the container host, as root, edit
/var/lib/containers/storage/volumes/var-pgsql/_data/postgresql.confand set these options:archive_mode = off archive_command = '/bin/true'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 创建完整备份
在容器主机上,以 root 身份执行以下命令创建备份:
mgradm backup create $path请将
$path替换为备份位置的路径。
2.2. SUSE Manager 的部分备份
mgradm backup create 工具允许创建部分备份。您可以跳过个别卷或所有卷、跳过数据库备份和映像。
特别是,当跳过数据库备份时,系统会创建备份而不停止 SUSE Manager 服务,备份可以作为两阶段备份流程中的一个阶段运行。
|
部分备份无法保证备份/恢复的一致性。 |
在容器主机上,以 root 身份执行以下命令创建备份:
mgradm backup create --skipdatabase $path请将
$path替换为备份位置的路径。
在容器主机上,以 root 身份执行以下命令创建备份:
mgradm backup create --skipvolumes $volumes $path请将
$path替换为备份位置的路径。Replace
$volumesby the name of the volume name to be excluded from the backup, or by a comma separated list of volumes to be excluded.使用
all可以跳过所有卷(数据库卷除外)。
2.3. 备份额外的卷
命令 mgradm backup 可使用 SUSE Manager 卷的内部列表。如果安装期间配置了其他卷,或有其他卷需要添加到备份中,则需使用 --extravolumes $volumes 指定这些卷。
在容器主机上,以 root 身份执行以下命令创建备份:
mgradm backup create --extravolumes $volume $path请将
$path替换为备份位置的路径。请将
$volumes替换为备份中要包含的某个卷或一系列以逗号分隔的卷名称。
2.4. Perform a manual database backup
请为备份分配永久存储空间。
在 SUSE Manager 容器主机的命令提示符处,以 root 身份执行以下命令:
mgradm backup create --skipvolumes all --skipconfig --skipimages $path
3. Restore SUSE Manager from the existing backup
从现有备份恢复 SUSE Manager 时,系统将枚举卷、映像和配置的备份以进行恢复。与创建备份的场景不同,恢复操作不使用内部卷列表,而是自动检测备份中存在的所有卷或映像。
收集待恢复项目列表后,会执行存在性和完整性检查。存在性检查用于确保恢复备份时不会意外覆盖现有卷、映像或配置。完整性检查通过计算备份项目的校验和完成。
两项检查均通过后,才会执行实际的备份恢复操作。
|
恢复操作完成后,SUSE Manager 服务不会自动启动。 |
在容器主机上以 root 身份运行以下命令,重新部署 SUSE Manager 服务器:
mgradm backup restore $path mgradm start请将
$path替换为备份位置的路径。
Verification of the backup can be a time-consuming operation. If backup integrity is ensured by other means, verification can be skipped by using --skipverify option.
如果出于某些原因需要跳过恢复备份中的某个卷,可以使用 --skipvolumes $volumes 选项。
3.1. Recommended steps after restoring a backup
使用 SUSE Manager Web UI 或在容器中的命令提示符处使用
mgr-sync工具重新同步您的 SUSE Manager 储存库。您可以选择重新注册产品,或跳过注册和 SSL 证书生成部分。On the container host, check whether you need to restore
/var/lib/containers/storage/volumes/var-spacewalk/_data/packages/. If/var/lib/containers/storage/volumes/var-spacewalk/_data/packages/was not in your backup, you need to restore it. If the source repository is available, you can restore/var/lib/containers/storage/volumes/var-spacewalk/_data/packages/with a complete channel synchronization:mgrctl exec -ti -- mgr-sync refresh --refresh-channelsSchedule the re-creation of search indexes next time the
rhn-searchservice 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