CentOS/RHEL Use yum Command To Downgrade or Rollback Updates
I
‘m a CentOS Linux 7.x server user. How can I use yum command to downgrade or rollback package updates on a RHEL (Red Hat)/CentOS/Scientific Linux server?
In this tutorial, you will learn:
How to downgrade installed packages using YUM
How to rollback installed package to previous version
The following examples only work on
CentOS or Red Hat Enterprise Linux 5.4+
CentOS or Red Hat Enterprise Linux 6.x+
CentOS or Red Hat Enterprise Linux 7.x+
YUM Downgrade syntax for CentOS/RHEL v5.4+ users
The basic syntax is:
yum downgrade package1
yum downgrade package1 package2
This syntax also works on a CentOS/RHEL v6.x/7.x but I recommend the following yum history method for all users.
Examples
To downgrade zsh, enter:
sudo yum downgrade zsh
Sample outputs:
Fig.01: YUM Downgrade Packages on Fedora, CentOS, Red Hat (RHEL) Linux
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 as follows:
sudo yum downgrade yum downgrade zsh-5.0.2-7.el7
YUM Downgrade syntax for CentOS/RHEL 6.x/7.x+ users
The syntax is:
## get list ##
yum history
Okay undo/downgrade it ##
yum history undo {NUMBER-HERE}
Examples
For demo purpose, I’m going to install/update zsh:
sudo yum install zsh
Now, list yum history:
sudo yum history
sudo yum history list
sudo yum history info
Sample outputs:
Loaded plugins: fastestmirror
ID | Login user | Date and time | Action(s) | Altered
11 | <veryv> | 2015-05-05 11:14 | Update | 1
10 | <veryv> | 2015-05-05 11:08 | Downgrade | 1
9 | <veryv> | 2015-05-05 10:56 | Install | 1
8 | <veryv> | 2015-05-05 10:56 | Install | 1
7 | <veryv> | 2015-05-05 09:59 | Update | 1
6 | System <unset> | 2015-04-23 20:02 | I, O, U | 156 EE
5 | System <unset> | 2015-04-23 20:02 | Install | 1
4 | System <unset> | 2015-04-23 20:02 | Install | 1 EE
3 | System <unset> | 2015-04-23 20:02 | Install | 1
2 | System <unset> | 2015-04-23 20:02 | Install | 1
1 | System <unset> | 2015-04-23 20:00 | Install | 280
history list
Let us undo (downgrade) ID #11 (i.e. the last action of zsh update):
sudo yum history undo 11
Sample outputs:
Loaded plugins: fastestmirror
Undoing transaction 11, from Tue May 5 11:14:21 2015
Updated zsh-5.0.2-7.el7.x86_64 @base
Update 5.0.2-7.el7_1.1.x86_64 @updates
Loading mirror speeds from cached hostfile
* base: mirror.web-ster.com
* extras: mirror.raystedman.net
* updates: centos-distro.cavecreek.net
Resolving Dependencies
–> Running transaction check
—> Package zsh.x86_64 0:5.0.2-7.el7 will be a downgrade
—> Package zsh.x86_64 0:5.0.2-7.el7_1.1 will be erased
–> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================
Package Arch Version Repository Size
===========================================================================================
Downgrading:
zsh x86_64 5.0.2-7.el7 base 2.4 M
Transaction Summary
===========================================================================================
Downgrade 1 Package
Total download size: 2.4 M
Is this ok [y/d/N]: y
Downloading packages:
zsh-5.0.2-7.el7.x86_64.rpm | 2.4 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : zsh-5.0.2-7.el7.x86_64 1/2
Cleanup : zsh-5.0.2-7.el7_1.1.x86_64 2/2
Verifying : zsh-5.0.2-7.el7.x86_64 1/2
Verifying : zsh-5.0.2-7.el7_1.1.x86_64 2/2
Removed:
zsh.x86_64 0:5.0.2-7.el7_1.1
Installed:
zsh.x86_64 0:5.0.2-7.el7
Complete!
Verify zsh package history, enter:
sudo yum history list zsh
Sample outputs:
Loaded plugins: fastestmirror
ID | Command line | Date and time | Action(s) | Altered
12 | history undo 11 | 2015-05-05 11:19 | Downgrade | 1
11 | install zsh | 2015-05-05 11:14 | Update | 1
10 | downgrade zsh | 2015-05-05 11:08 | Downgrade | 1
8 | install zsh | 2015-05-05 10:56 | Install | 1
history list
A note about performing downgrades
There are a number of problems with performing downgrades. I’ll cover a few of them here (quoting from here):
* Scriptlets are not reversible: rpm scriptlets provide no way to reverse the process(es) they executed. For example a scriptlet (%pre, %preun, %post, %postun, etc) may run echo “Foo foo foo” >> /etc/some/file. There’s no way to undo that when you perform a downgrade.
- Downgrading works provided the user data/user config is not modified by an update in a one-way process.
- Examples: mysql upgrade from 4->5 will convert a db, but going back the other way won’t fly
- * Upgrading a desktop application from one version to the next major version modifies config files in such a way but cannot modify them back.
- * There are certain processes which no one is ever going to do the work to make them reversible: lvm1->lvm2, db transitions, udev migration, ext3->ext4.
- Currently the depsolver doesn’t work very well for downgrades, as it can’t downgrade extra packages. However you can use tools like yum-debug-dump and yum-debug-restore, which should include all packages needed.
- * There is now a downgrade command.