• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 6,7 : How to use yum history to roll back a yum update

By admin

Note : Rollback of selinux, selinux-policy-*, kernel, glibc (dependencies of glibc such as gcc) packages to older version is not supported. Thus, downgrading a system to minor version (ex: RHEL6.6 to RHEL6.5) is not recommended as this might leave the system in undesired state. Use the yum history option for small update rollbacks.

How yum stores the transaction history

yum stores a sqlite database of information about each transaction. The history is organized 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 the below command :

# yum history info [transaction_ID]

Rolling back a RPM uninstallation

Let us see an example of rolling back an uninstall of a package (firefox).
1. Check the previously installed version of firefox :

# rpm -qa | grep -i firefox
firefox-52.0-5.el7_3.x86_64         ======> Current version of rpm

2. Now Remove firefox package

# yum remove firefox

3. Now check all the past yum transactions using the command yum history:

# yum history
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    20 | root [root]              | 2017-05-24 09:48 | Erase          |    1    ====>  the firefox rpm removed here   
    19 | root [root]              | 2017-05-24 09:47 | I, U           |   14   
    18 | root [root]              | 2017-05-05 07:13 | Install        |    1  <
    17 | System [unset]           | 2016-12-27 16:46 | Update         |    2 > 
    16 | root [root]              | 2016-10-19 16:02 | Install        |    1  <
    15 | root [root]              | 2016-05-14 14:18 | Install        |    1 > 
    14 | root [root]              | 2016-05-14 13:52 | Install        |    4   
    13 | root [root]              | 2016-05-14 13:37 | Install        |    2   
    12 | root [root]              | 2016-05-14 13:35 | Install        |   88   
    11 | root [root]              | 2016-05-14 13:17 | Install        |    1   
history list

4. Now roll back the uninstall of the package using the yum history undo command. Note the transaction ID 20 of the firefox package uninstall transaction. The latest transactions are always at the top of the table.

# yum history undo 20
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Undoing transaction 20, from Wed May 24 09:48:41 2017
    Erase firefox-52.0-5.el7_3.x86_64 @BAVA
Resolving Dependencies
--> Running transaction check
---> Package firefox.x86_64 0:52.0-5.el7_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================
 Package                                      Arch                                        Version                                              Repository                                 Size
===============================================================================================================================================================================================
Installing:
 firefox                                      x86_64                                      52.0-5.el7_3                                         BAVA                                       83 M

Transaction Summary
===============================================================================================================================================================================================
Install  1 Package

Total download size: 83 M
Installed size: 150 M
Is this ok [y/d/N]: y
Downloading packages:
firefox-52.0-5.el7_3.x86_64.rpm                                                                                                                                         |  83 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : firefox-52.0-5.el7_3.x86_64                                                                                                                                                 1/1 
  Verifying  : firefox-52.0-5.el7_3.x86_64                                                                                                                                                 1/1 

Installed:
  firefox.x86_64 0:52.0-5.el7_3                                                                                                                                                                

Complete!

5. Above command Roll backed the previous transaction. You can check the firefox rpm now. You should get the exact same version which was installed previously.

# rpm -qa | grep -i firefox
firefox-52.0-5.el7_3.x86_64
Doing full system backup prior to any update is always recommended, and yum history is NOT meant to replace systems backups.

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. pvcreate Fails With Error: “Device /dev/mapper/mpatha Not Found (or Ignored By Filtering).”
  2. CentOS / RHEL 7 : How to change runlevels (targets) with systemd
  3. CentOS / RHEL 7 : How to Change the machine-id
  4. How to disable NetworkManager on CentOS / RHEL 7
  5. How to scan newly Assigned LUNs in Multipathd under CentOS / RHEL
  6. How to Resize / Expand a Btrfs Volume / Filesystem
  7. How to Enable IPv6 In CentOS / RHEL 5
  8. How to enable bind query logging to find out Who’s Querying a Name Server
  9. How to Ignore/Disable Specific auditd Logging Entries
  10. Understanding The /proc File System

You May Also Like

Primary Sidebar

Recent Posts

  • What are different Oracle Database Vault Roles
  • Unable to export realm protected table using data pump
  • Beginners Guide to Oracle Database Vault
  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary