Rolling Back Your System with RPM

Configuring a rollback capability in your system is just a matter of taking a few well-planned steps. They involve creating some macros for the rpm system, choosing a "safe point" - the point in time before which you won't want to roll back your system - and creating an archive directory for rpms replaced by new versions.

Each time you update or uninstall an rpm package in a rollback-enabled system, the rpm is actually repackaged and archived. It's not deleted. That allows you the capability to re-install that package at any time.

Further, the system allows you to use an intuitive rollback criteria, such as `rpm -Uvh --rollback '3 days ago'`. This is done by the use of a field in the rpm database known as the Transaction ID (TID). The repackaged package is also noted with the TID. When rolling back, any package equal to or older than the requested TID (as interpreted from the plain-english time) is re-installed on the system. You can also rollback one particular package by `rpm -Uvh --rollback <package>`.

To enable rollbacks, follow these simple steps.

1. Calculate the Unix time for your target rollback date with the following:

$ date --date="01/18/2005" +%s

This will be the Unix time used below.

2. If it doesn't already exist, create the /etc/rpm/macros file containing the following three lines:

%_repackage_all_erasures 1
%_unsafe_rollbacks <Unix time in seconds>
%_repackage_dir /var/spool/repackaged_rpms

3. Create the _repackage_dir on your system.

If you're one of the those practical RPM users out there that use Up2date to install the latest packages, you must enable the RPM rollback feature in your configurations for up2date to use your handy rollback system you just implemented. To do this do a 'up2date-config' and select the setting allow rollbacks of the RPMs. To rollback your last update you can now just do a `up2date –undo`.

Now, as you remove or update packages on your system, each will be repackaged and stored in the directory you've noted in the "/etc/rpm/macros" file. The package and all files related to it will be repackaged and stored in the archive before the originals are deleted.