Linux : How to rollback Yum updates on RHEL/CentOS

By | August 13, 2012

Having issues and downtime after installing latest updates using “yum update” is always a possibility. This is why having a development environment is so much important when you are running a mission critical infrastructure.

However, there is an intermediate solution : using the rollback feature included in Yum. Note this option is actually not enabled by default.

1. To enable rollback, simply edit the Yum config file and add the following setting :

vi /etc/yum.conf

And add :

tsflags=repackage

Okay, now it’s enabled and will be effective for every new update you install. You’ll notice a new action named “Repackage” before the usual “Updating” stage is shown.

2. Add the following line into the rpm macro file (create if non-existent) :

vi /etc/rpm/macros

And add :

%_repackage_all_erasures 1

3. Now you can use the following command to go back in time :

rpm -Uvh –rollback ’21:00′
rpm -Uvh –rollback ’3 hours ago’
rpm -Uvh –rollback ‘august 13′
rpm -Uvh –rollback ‘yesterday’

Note : All previous repackaged software will be stored into :

/var/spool/repackage