[RHEL6] Using yum to roll back an update(s)

Latest response

Hello Techs!


I want to share with you the following.


Did you know that RHEL 6 includes the yum history module?  You can use this to rollback any updates done with the 'yum' command.

Check out this example: http://people.redhat.com/rprice/yum_history.txt

With this command, you can choose an update 'yum' issued and remove those selected packages.

From the yum man page:



The history command allows the user to view what has happened in past transactions (assuming the history_record config. option is set). You can use info/list/summary to view what happened, undo/redo to act on that information and new to start a  new history

The info/list/summary  commands  take either a transaction id or a package (with wildcards, as in Specifying package names), all three can also be passed no arguments. list can be passed the keyword "all" to list all the transactions.

The undo/redo commands take either a transaction id or the keyword last and an offset from the last transaction  (Eg.  if you’ve done 250 transactions, "last" refers to transaction 250, and "last-4" refers to transaction 246).

The addon-info command takes a transaction ID, and the packages-list command takes a package (with wildcards).

In "history  list" output the Altered column also gives some extra information if there was something not good with the transaction (this is also shown at the end of the package column in the packages-list command).

> - The rpmdb was changed, outside yum, after the transaction.
< - The rpmdb was changed, outside yum, before the transaction.
* - The transaction aborted before completion.
# - The transaction completed, but with a non-zero status.
E - The transaction completed fine, but had warning/error output during
the transaction.
P - The transaction completed fine, but problems already existed in the rpmdb.
s - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.


We have done a test with this command.  We upgraded from RHEL6.0 to RHEL6.1 and did a rollback with using yum.  This command completed but left the system in a "broken" state where libgcc and others library's did not rollback correctly.  We suspect it's likely because SPEC files aren't written with rolling back in mind.  Make note of this.  For small update rollbacks, this appears to be working great!

Hope this proves to be useful for someone. 

I'd appreciate your feedback and comments



We have done testing with this feature as it really comes in handy, using Rhel 6.1 as a starting point, patching to 6.2, then rolling back to 6.1 worked as expected; the only extra manual step was to remove the 6.2 kernel.  The same process also worked from patching 6.2 to 6.3, then rolling back to 6.2.  To do the rollback,

yum history

to see your checkpoints, then to roll back based on your checkpoint (here assuming checkpoint 2)

yum history undo 2


The one gotcha that bit us when rolling back was the system needs to still be able to see the old yum repositories that contain the previous patchset data (ie to roll back from 6.2 to 6.1, you need to be able to see the 6.1 content)