문제

•How can I backup a currently installed RPM before upgrading it?

환경

•Red Hat Enterprise Linux 4
•Red Hat Enterprise Linux 5
•Red Hat Enterprise Linux 6

해결

RHEL 4와 5 버전은 –repackage 옵션을 주고 설치하면 /var/spool/repackage 디렉토리에 기존 rpm이 남게된다.

또는 기존 rpm을 따로 가지고 있다면 –oldpackage

Red Hat Enteprise Linux 4 and Red Hat Enteprise Linux 5

Following method is not supported and it is is given for informative purpose only and it was disabled in rhel6. It is strongly recommended not to use this method.
•Install a package with a –repackage option. This will create an RPM from the existing package and install the new one.Here is an example to show how the whole process works:
# rpm -Fvh –repackage /var/spool/up2date/hwdata-0.146.23.EL-1.noarch.rpm
Preparing… ###########################################
[100%]
Repackaging…
1:hwdata ###########################################
[100%]
Upgrading…
1:hwdata ###########################################
[100%]

Then the package for the old RPM is created in /var/spool/repackage/ directory.

Note: The –repackage option needs to be used with the -Fvh options.

Red Hat Enterprise Linux 6

•The flags repackage and rollback have been deprecated in RHEL 6.

•You now have to use the yum history utility to rollback to a previous version of the RPM you've just upgraded. You can find more information on the upstream project here

[root@server ~]# yum history info
Loaded plugins: product-id, refresh-packagekit, rhnplugin
This system is receiving updates from RHN Classic or RHN Satellite.
Transaction ID : 45
Begin time : Tue Sep 30 16:20:28 2014
Begin rpmdb : 732:171881e1ac2d2e81c4d561f6d8800ea323e5a956
End time : 16:20:41 2014 (13 seconds)
End rpmdb : 732:9c9ea7d3e5afcdead20b2d086e835cc08a70d103
User : root <root>
Return-Code : Success
Command Line : update bash
Transaction performed with:
Installed rpm-4.8.0-32.el6.x86_64 @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
Installed yum-3.2.29-40.el6.noarch @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
Installed yum-metadata-parser-1.1.2-16.el6.x86_64 @anaconda-RedHatEnterpriseLinux-201301301459.x86_64/6.4
Packages Altered:
Updated bash-4.1.2-15.el6_5.1.x86_64 @rhel-6-server-rpms
Update 4.1.2-15.el6_5.2.x86_64 @rhel-x86_64-server-6
history info

•Now you can rollback the command and revert back to the old bash RPM, last is the latest transaction, so you will have to user last-1 to revert back to previous version
[root@server ~]# yum history rollback last-1
Loaded plugins: product-id, refresh-packagekit, rhnplugin
This system is receiving updates from RHN Classic or RHN Satellite.
Rollback to transaction 44, from Mon Sep 29 12:06:48 2014
Undoing the following transactions: 45
Updated bash-4.1.2-15.el6_5.1.x86_64 @rhel-6-server-rpms
Update 4.1.2-15.el6_5.2.x86_64 @rhel-x86_64-server-6
Resolving Dependencies
–> Running transaction check
—> Package bash.x86_64 0:4.1.2-15.el6_5.1 will be a downgrade
—> Package bash.x86_64 0:4.1.2-15.el6_5.2 will be erased
–> Finished Dependency Resolution

•You can also install RPM yum-utils and use "yumdownloader" utility to download a specific version of a package to your system for later use
[root@server ~]# yum install yum-utils

[root@server ~]# yumdownloader bash-4.1.2-15.el6_5.1.x86_64 –destdir=/tmp/
Loaded plugins: product-id, refresh-packagekit, rhnplugin
This system is receiving updates from RHN Classic or RHN Satellite.
bash-4.1.2-15.el6_5.1.x86_64.rpm

[root@server ~]# ls -l /tmp/bash-4.1.2-15.el6_5.1.x86_64.rpm
-rw-r–r–. 1 root root 926472 Sep 24 11:11 /tmp/bash-4.1.2-15.el6_5.1.x86_64.rpm

RHEL 4, 5, 6 rpm rollback

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다