Downgrade package using yum


We have used yum to install or upgrade the application on RHEL/Fedora like systems, however the rollback or downgrade is rarely required.

Rollback or Downgrade the package to the previous version in the repo

In order to rollback or downgrade the package to the previous version in the repository using yum, you use the downgrade option for yum. Please note this option will work best if the repository you are using proper version/revision data.

The following is the syntax:

yum downgrade packagename

The following is the example command with the expected results:

[root@gagan ~]# yum downgrade my_package

Output:

Loaded plugins: fastestmirror
Setting up Downgrade Process
Loading mirror speeds from cached hostfile
 * centos-base: mirrors.cmich.edu
 * centos-updates: mirror.raystedman.net
 * epel: linux.mirrors.es.net
Resolving Dependencies
--> Running transaction check
---> Package my_package.x86_64 0:2 set to be updated
---> Package my_package.x86_64 0:3 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                     Arch                               Version                                     Repository                             Size
========================================================================================================================================================================
Downgrading:
 my_package                    	 	    x86_64                             	   2 		                             centOS                               970 k

Transaction Summary
========================================================================================================================================================================
Remove        0 Package(s)
Reinstall     0 Package(s)
Downgrade     1 Package(s)

Total download size: 970 k
Is this ok [y/N]: y
Downloading Packages:
my_package-2.x86_64.rpm                                                                                                          |  970 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : my_package                                                                                                                                  1/2 
  Cleanup        : my_package                                                                                                                                  2/2 

Removed:
  my_package.x86_64 0:3                                                                                                                                 

Installed:
  my_package.x86_64 0:2                                                                                                                                 

Complete!

Install previous version for a installed package using yum yum-allowdowngrade

In case you need to use yum to install an old version for an installed package which is quiet a few revisions older than the current version, you need to use the yum-allowdowngrade plugin for yum which will allow you to install the older version from the repository.

So first we will install yum-allowdowngrade using yum-

[root@gagan ~]# yum install yum-allowdowngrade

Output:

Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.5ninesolutions.com
 * extras: centos-distro.cavecreek.net
 * updates: mirrors.arpnetworks.com
addons                                                                                                                                           | 1.9 kB     00:00     
base                                                                                                                                             | 1.1 kB     00:00     
extras                                                                                                                                           | 2.1 kB     00:00     
extras/primary_db                                                                                                                                | 179 kB     00:00     
updates                                                                                                                                          | 1.9 kB     00:00     
updates/primary_db                                                                                                                               | 594 kB     00:00     
Excluding Packages in global exclude list
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum-allowdowngrade.noarch 0:1.1.16-21.el5.centos set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                       Arch                              Version                                          Repository                       Size
========================================================================================================================================================================
Installing:
 yum-allowdowngrade                            noarch                            1.1.16-21.el5.centos                             base                             13 k

Transaction Summary
========================================================================================================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 13 k
Is this ok [y/N]: y
.
.
.

Once you have done installing this plugin, you can now install any older version for package using yum.

In this example let’s consider example for postgresql-server. We currently have postgresql-server-8.1.23-5.el5_8 and we would like to downgrade it to postgresql-server-8.1.11-1.el5_1.1.

So first we will remove the current package and it’s dependencies using yum remove.

[root@gagan ~]# yum remove postgresql-server postgresql-libs

Once done, use yum to installed the older versions of the package and their dependencies

[root@gagan ~]# yum –allow-downgrade install postgresql-server-8.1.11-1.el5_1.1 postgresql-libs-8.1.11-1.el5_1.1

The above should install the older version of postgresql-server and the required libraries.

Rollback using rpm rollback switch

There is also a rollback option available using the rpm command, which I would like to discuss after more research.

Tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


6 − 4 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>