如何进行yum备份和恢复?
有没有办法对 yum 更新时会更改的包进行备份?例如,当我执行 yum update lighttpd 时,如果 yum update 不成功或者会导致意外的错误或错误,是否有办法备份和恢复 lighttpd?
Is there a way to make a backup of package that will be change while yum update? For example when I do yum update lighttpd is there a way to backup and restore lighttpd if yum update will be unsuccessful or it will result in unsuspected errors or bugs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在 4.6.0 之前使用 RPM(它已在较新版本中删除),您可以使用
rpm --rollback
机制,如 在这篇旧教程中或在一篇更完整的文章中,其中包含一些内容功能解释。 --rollback 功能是一个自动解决方案,由于不可靠而被删除。您可以使用手动解决方案,在 yum 更新之前保留所有软件包的列表,并重新安装所需的旧 rpm,可能使用 --oldpackage,如 rpm -Uvh - -oldpackage foo-1-1.i386.rpm:
获取所有已安装软件包的列表,按安装时间排序:
(来源)
如果您使用 Fedora,这里是使用安装程序升级系统的官方指南,其中包含如何创建 < a href="http://docs.fedoraproject.org/en-US/Fedora/13/html/Installation_Guide/sn-upgrade-tree-x86.html" rel="nofollow noreferrer">系统当前安装的软件包列表 以及如何恢复大多数旧软件升级后。
如果您想要一种通用方法来获取已安装软件的列表(不仅仅是基于 rpm),您可以按照 本文也是如此。
If you're using RPM before 4.6.0 (it's removed in newer versions), you can use
rpm --rollback
mechanism like in this old tutorial or in a more complete article with some functionality explanation. The --rollback feature is an automatic solution that was removed since it isn't reliable.You can have a manual solution, keeping a list of all the packages before the yum update and reinstall needed old rpms possibly using --oldpackage like
rpm -Uvh --oldpackage foo-1-1.i386.rpm
:To get a list of all installed packages, sorted by installation time:
(Source)
If you're using Fedora, here is an official guide to upgrade the system using the installer with an example of how to create a list of system current installed packages and how to restore most of old software after an upgrade.
If you want a generic approach to get a list of installed software (not only rpm based), you can follow this article as well.
如果您使用的是存储库。保留所有旧版本,您只需执行“yum downgrade lighttpd”(以及较新的 yum 的“yum History undo”)。如果不是,那么您可以保留旧 rpm 的本地副本并使用“yum downgrade lighttpd*.rpm”(尽管这比较棘手)。
有些问题可能无法通过此解决,但这些问题应该非常罕见,降级不太可能改变任何其他副作用。
最近创建了一个插件“yum-plugin-fs-snapshot”,它将在升级之前自动拍摄 FS 快照(btrfs 或 LVM)......因此。然后您可以回滚到快照。不过,这是一个很大的改变,所以我不推荐它。
If you are using a repo. that keeps all old versions around, you can just do "yum downgrade lighttpd" (and with newer yum's "yum history undo"). If you aren't, then you can keep a local copy of the old rpm and use "yum downgrade lighttpd*.rpm" (although that is trickier).
It's possible that some problems won't be fixed by this, but those should be very rare and downgrade is unlikely to change anything else as a side effect.
Very recently a plugin "yum-plugin-fs-snapshot" has been created, which will automatically take an FS snapshot (btrfs, or LVM) before doing an upgrade ... thus. you can then just rollback to the snapshot. This is a big change though, so I don't recommend it.
我使用 etckeeper 来跟踪
/etc
下文件的更改。 etckeeper 将/etc
置于版本控制之下(它支持多种版本控制系统,包括 Git、Mercurial 和 Bazaar),并与许多 Linux 发行版(APT、YUM、Pacman)的包管理系统集成。如果在升级过程中出现问题,我可以回滚任何内容。
I use etckeeper to track changes of files under
/etc
. etckeeper puts/etc
under version control (it supports multiple version control systems, including Git, Mercurial and Bazaar) and integrates with the package management systems of a number of Linux distros (APT, YUM, Pacman).If something bad happens during an upgrade or so, I can rollback anything.