How to use yum/dnf to downgrade or rollback some package updates?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.4 and later
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9

Issue

  • How to rollback or downgrade installed package to previous version?
  • How to use yum to downgrade or rollback some package updates?
  • What is the best practice for rollback package ?
  • How to use yum downgrade option ?
  • Is it possible to find the OS update history for transactions performed with yum ?
  • How to downgrade my java version to 1.8.0.252?

Resolution

Warning: Rollback or downgrade of the following packages is unsupported as the packages themselves, and dependencies, either assume an update-only or install-only process:

  • dbus
  • glibc (dependencies of glibc such as gcc)
  • selinux-policy*

Thus, downgrading a system to minor version (ex: RHEL8.5 to RHEL8.4 or RHEL7.9 to RHEL7.8) is not recommended as this might leave the system in an undesired state. If this operation is attempted, it is strongly recommended to only do so with working system backups in place. In general, use the yum history option is intended for small update rollbacks.

Please read the following guides for additional information:

Red Hat Enterprise Linux 5 :

  • In Yum 3.2.22, which come with Red Hat Enterprise Linux 5.4, there is a downgrade option. This will downgrade a package to the previously highest version or you can specify the whole version and release number for the package to downgrade. For example:

    [root@host ~]# yum downgrade vsftpd-2.0.5-12.el5
    
  • Note that this may also remove the packages that depends on the current version of the package. Usually, for some closely related packages, you may want to downgrade them all together. Otherwise, yum will remove the closely related packages in order to satisfy the dependency requirement.

  • For example, if you want to downgrade httpd :

    [root@host ~]# yum downgrade httpd-2.2.3-22.el5
    [snip]
    Dependencies Resolved
    
    ========================================================================================================================
     Package                     Arch                Version                        Repository                         Size
    ========================================================================================================================
    Installing:
     httpd                       i386                2.2.3-22.el5                   rhel-i386-server-5                1.2 M
    Removing:
     httpd                       i386                2.2.3-31.el5                   installed                         3.1 M
    Removing for dependencies:
     httpd-manual                i386                2.2.3-31.el5                   installed                         3.4 M
     mod_ssl                     i386                1:2.2.3-31.el5                 installed                         173 k
    
    Transaction Summary
    ========================================================================================================================
    Install      1 Package(s)         
    Update       0 Package(s)         
    Remove       3 Package(s)    
    
    Total download size: 1.2 M
    Is this ok [y/N]:
    
  • The httpd-manual and mod_ssl packages will also be removed (instead of downgrade) because the downgraded httpd cannot satisfy the dependency of the current version httpd-manual and mod_ssl.

  • To downgrade them altogether, you can add them in the command:

    [root@host ~]# yum downgrade httpd-2.2.3-22.el5 httpd-manual-2.2.3-22.el5 mod_ssl-2.2.3-22.el5
    
    Dependencies Resolved
    
    ========================================================================================================================
     Package                     Arch                Version                        Repository                         Size
    ========================================================================================================================
    Installing:
     httpd                       i386                2.2.3-22.el5                   rhel-i386-server-5                1.2 M
     httpd-manual                i386                2.2.3-22.el5                   rhel-i386-server-5                833 k
     mod_ssl                     i386                1:2.2.3-22.el5                 rhel-i386-server-5                 87 k
    Removing:
     httpd                       i386                2.2.3-31.el5                   installed                         3.1 M
     httpd-manual                i386                2.2.3-31.el5                   installed                         3.4 M
     mod_ssl                     i386                1:2.2.3-31.el5                 installed                         173 k
    
    Transaction Summary
    ========================================================================================================================
    Install      3 Package(s)         
    Update       0 Package(s)         
    Remove       3 Package(s)   
    
    Total download size: 2.1 M
    Is this ok [y/N]:
    
  • Here we can see that the newer version of httpd, httpd-manual and mod_ssl altogether are reinstalled with the older version of those RPMs, and no package is going to be removed for dependencies.

  • Problems with performing downgrade:

    • Downgrades are tricky but in yum versions 3.2.27 and above it can do _some_ downgrades. They are not perfect and should be used with care
    • Refer to yum.baseurl.org for more details.

Red Hat Enterprise Linux 6 and 7 :

  • yum stores a sqlite database of information about each transaction. The history is organized in terms of transaction IDs and is updated every time a yum transaction affects the package configuration of the system. Mostly this database can be found in the /var/lib/yum/history/ directory.

  • The yum history command allows the user to view the history of transactions.

  • The following command lists the history of all transactions :-

    # yum history list all
    
  • This will list the transaction ID along with the date and time, the actions performed and the number of packages altered.

  • For more information on a particular transaction, note the transaction ID for that transaction and use it in this command :-

    # yum history info <transaction_ID>
    
  • Red Hat Enterprise Linux 6 and 7 comes with the yum history option, see : How to use yum history to roll back an update in Red Hat Enterprise Linux 6 and later

Red Hat Enterprise Linux 8 and 9 :

  • dnf stores a sqlite database of information about each transaction. The history is organized in terms of transaction IDs and is updated every time a yum/dnf transaction alters the package configuration of the system. Mostly this database can be found in the /var/lib/dnf/history/ directory.

  • The dnf history command allows the user to view the history of transactions.

  • The following command lists the history of all transactions :-

    # dnf history list
    
  • This will list the transaction ID along with the date and time, the actions performed and the number of packages altered.

  • For more information on a particular transaction, note the transaction ID for that transaction and use it in this command :-

    # dnf history info <transaction_ID>
    
  • Red Hat Enterprise Linux 8 and 9 can undo a transaction with dnf history. yum is an alias to dnf so the terms are used interchangably : How to use yum history to roll back an update in Red Hat Enterprise Linux 6 and later

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments