How to revert a yum update on CentOS

- by

Every so often, a yum update brings unexpected results with it, like services no longer working due to spurious error messages that don’t tell you what’s actually wrong. This only very rarely happens though, and we may need to revert to the state of our system before such an update took place.

Thankfully, yum has a nice feature that helps us do this, namely yum history.

yum history
Loaded plugins: fastestmirror, refresh-packagekit
ID | Login user | Date and time | Action(s) | Altered
——————————————————————————-
86 | root <root> | 2019-07-12 11:13 | I, O, U | 11 EE
85 | root <root> | 2019-07-12 11:09 | Install | 1
84 | root <root> | 2019-07-12 10:43 | E, I, U | 19 EE
83 | root <root> | 2019-05-06 08:59 | E, I, U | 27 EE
82 | root <root> | 2018-12-19 22:41 | Update | 2
81 | root <root> | 2018-12-17 11:03 | E, I, U | 9 EE
80 | root <root> | 2018-11-09 16:55 | Update | 3
79 | root <root> | 2018-10-18 15:19 | Update | 1
78 | System <unset> | 2018-10-09 22:27 | E, I, U | 20 EE
77 | root <root> | 2018-09-09 10:04 | E, I, U | 10 EE
76 | root <root> | 2018-07-19 18:34 | E, I, U | 119 EE
75 | root <root> | 2018-05-21 13:08 | E, I, U | 12 EE
74 | root <root> | 2018-05-10 11:20 | Erase | 9
73 | root <root> | 2018-05-10 11:16 | Install | 1
72 | root <root> | 2018-05-10 11:15 | Erase | 1
71 | root <root> | 2018-05-10 11:05 | Install | 1
70 | root <root> | 2018-05-04 09:20 | Update | 4
69 | Jay Versluis <versluis> | 2018-05-01 10:16 | E, I, U | 34 EE
68 | root <root> | 2018-02-16 09:57 | Update | 8 PP
67 | root <root> | 2018-02-16 09:51 | E, I, U | 21 **
history list
view raw yum history hosted with ❤ by GitHub

The command will bring up the latest 20 transactions by default, be those installs, updates or removals. There’s a transaction ID at the very front of each line, with which we can tell yum to undo said transaction. In my case, transaction 86 didn’t work out so well, so let’s undo whatever has happened there (in my case, a combination of installs, updates and overwrites).

Let’s revert those changes with yum history undo 86

The familiar text output comes up, eventually showing a list of packages that will be affected. Confirm those changes with y and let yum do it’s job.

Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php-mysql i686 5.4.45-56.el6.art atomic 461 k
Removing:
gd-last i686 2.2.5-5.el6.remi @remi-safe 372 k
libargon2 i686 20161029-7.el6.remi @remi-safe 58 k
libwebp i686 0.4.3-3.el6.art @atomic 658 k
php-json i686 7.3.7-3.el6.remi @remi-php73 72 k
php-mysqlnd i686 7.3.7-3.el6.remi @remi-php73 708 k
Downgrading:
php i686 5.4.45-56.el6.art atomic 8.0 M
php-cli i686 5.4.45-56.el6.art atomic 3.0 M
php-common i686 5.4.45-56.el6.art atomic 1.7 M
php-gd i686 5.4.45-56.el6.art atomic 509 k
php-pdo i686 5.4.45-56.el6.art atomic 349 k
Transaction Summary
================================================================================
Install 1 Package(s)
Remove 5 Package(s)
Downgrade 5 Package(s)
Total download size: 14 M
Is this ok [y/N]: y

After a few moments, our system has been restored to a state from before the update occurred, hopefully back into a running state.

There’s another interesting option called yum history rollback (ID). This will let us go back more than one step in our list, restoring the changes made by multiple transactions. Vivke’s article has more information on this.



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

1 thought on “How to revert a yum update on CentOS”

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.