Exploring the yum package manager

Rollback Function

You are probably familiar with the situation in which you install a new program but then need to restore the original state of the system because of incompatibilities, bugs, or other problems. This rollback can be fairly tricky – for one thing, older packages might be difficult to locate, and for another, the configurations might have been overwritten. An automatic rollback function is often the quickest, simplest, and cleanest approach.

To leverage the benefits of package rollback, you need to back up the current system status before you change the selection of packages – that is, whenever you install or delete packages. To help you do so, RPM has a repackage function.

The repackage process bundles the relevant files, such as configuration files, data, and program files, into a new RPM archive. The RPM repackage function adds a transaction ID to each archive and stores the archive at a fixed location.

To restore a previous installation state, remove the packages you just installed and install the repackage files you created before doing so.

To tell RPM which repackage files to install, each RPM transaction is assigned a unique number. If you delete multiple packages and their dependencies, all the repackage files will have a unique transaction ID. According to the RPM manpage, the ID is a simple Unix timestamp.

Yum can use RPM's rollback functionality if you enable the feature in the configuration files. To do so, add the following entry to /etc/rpm/macros:

%_repacke_all_erasures 1

If the /etc/rpm/macros configuration file does not exist, you need to create it. Then add the following line to the /etc/yum.conf file:

tsflags=repackage

Once you have configured this parameter, the system will "remember" every status setting in the /var/spool/repackage folder. If you delete a package, something such as

# rpm -Uhv --rollback '3 minutes ago'

will restore the system state from three minutes ago.

Test Run

Additionally, specifying --test will perform a test run and show you the actions to perform, but without actually executing the rollback. You can specify the time for the rollback as follows:

# rpm -Uhv --rollback 'YYYY-MM-DD HH:MM'

If you can't remember the time for the installation you want to roll back, just check the timestamps on the repackage files in /var/spool/repackage.

The Author

Daniel Niedzielski is a software developer. He has a family with three children, and he is currently studying Computer Science in distance learning at the University of Hagen and working on his LPIC-2 certification.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Installing Software

    We provide an introduction to installing and managing RPM packages.

  • Fedora Core 5

    Fedora opens the spring fashion season with a bold new release. We took a look at the latest collection.

  • Smart Package Manager

    The package manager is one of the central components on any Linux system. If you have a system with unreliable package management – such as Suse Linux 10.1 – you may want to consider the Smart alternative.

  • Fedora Core 3 Preview

    Version 3 of Red Hat’s free community-supported Fedora Core distribution will be available by the time you read this article.On the surface, very little has changed,but under the hood,Core 3 has innovations designed to improve the user experience.We investigated the final release candidate,and here’s what we found.

  • Getting Rid of Old Kernels

    When you update the kernel, the old version remains on the disk. If you clean up, the reward is several hundred megabytes of free disk space.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News