Sometimes the software update won’t work as expected, this may lead to application down or some other incident or events. If its happen we have to have some quick fix, so end user wont feels any more downtime and some other issues. Here will see How can we use yum command to downgrade or rollback package updates on a RHEL (Red Hat)/CentOS Linux server?
YUM Downgrade syntax for CentOS/RHEL v5.4+ users
Basic Syntex:
# yum downgrade package1 # yum downgrade package1 package2
Example To downgrade httpd, enter: # yum downgrade httpd
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:
# yum downgrade httpd-2.2.15-59.el6.centos.x86_64
You Can get the package details with version using;
# rpm –qa | grep httpd
YUM Downgrade syntax for CentOS/RHEL 6.x/7.x+ users
The syntax is:
# yum history # yum history undo {NUMBER-HERE}
Examples
For demo, lets install/update httpd: # yum install httpd Now, list yum history: # yum history # yum history list # yum history all
Let us undo (downgrade) ID #11 # yum history undo 11 Verify httpd package history, enter: # yum history list httpd
Problems with performing downgrades
There are a number of problems with performing downgrades. I’ll cover a few of them here: (Referred from BaseURL)
- 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.