YUM Tutorial: Undo Package Updates with Rollback

In almost all situations, keeping your server up-to-date with the latest packages is the smart thing to do. In some cases, however, updates (especially more involved upgrades) may cause certain web applications to stop functioning properly or may introduce a new bug that the developers missed.

To make sure you do not get one of these updates, you should always check change logs and read news and comments/forum posts about the updates. If you wait a few days or even a week, you may find out things about the update that you would not have known if you updated right away. On the other hand, waiting longer than that could put your server in jeopardy, if the updates are related to security.

Despite your best efforts, there may be times when you will not know the effect of an update or new package installation until after your system has performed it.  When that happens, you can use RPM’s rollback utility to undo any damage.

First, you have to have the repackage feature enabled ahead of time. In /etc/yum.conf, make sure you have this line: tsflags=repackage.

Next, edit the rpm configuration file and add the following to /etc/rpm/macros.

%_repackage_all_erasures 1

From that point forward, whenever you install or update  packages with yum, rpm, or even another tool, you can rollback to a previous time before the actions you took. For example:

rpm -Uhv –rollback ’14:00′

This will take you back to your package system’s status before 2PM. Anything you installed during the window of time you specify will be removed, restoring your system to its previous working state.

Additionally, you can also use regular language like:

rpm -Uhv –rollback ’9 hours ago’

or rollback to days rather than specific hours:

rpm -Uhv –rollback ‘yesterday’

For more information about rpm and its different functions, read the online documentation.











Comments: