<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d11356004\x26blogName\x3dxception\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://openrent.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://openrent.blogspot.com/\x26vt\x3d-2179510228592399674', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

RPM rollbacks

Ever use up2date to upgrade a Red Hat server, only to have a newly-upgraded package cause a problem? You have to uninstall the offending package, find the old version, download it, and install it. These time-consuming activities can be avoided by using a little-known feature of RPM called "rollbacks."

RPM rollbacks give you the ability to roll-back an upgrade to the previous (last-known good?) version. Here's how it works: RPM packages, whether installed individually or in a group, are given a unique Transaction ID (TID) in the RPM database. This allows RPM to track which transaction installed or upgraded a specific RPM. These TID's are what the rollback mechanism uses to work its magic.

The other element needed is the RPM (or set of RPM's) that were on the system prior to the upgrade/install. The rollback mechanism solves this problem by repackaging the existing RPM's before they get erased. These "repackaged" packages are stored in the /var/spool/repackage directory.

To enable rollbacks, get into the up2date management console with the "u2pdate --configure" command, and change the "enableRollbacks" option to "Yes."

The next time there are packages to be updated, here is what it will look like:

# up2date -u

Fetching Obsoletes list for channel: rhel-x86_64-as-4...
########################################

Fetching rpm headers...
########################################

Name Version Rel
----------------------------------------------------------
nss_ldap 226 17 x86_64
openssh 3.9p1 8.RHEL4.17.1 x86_64
openssh-clients 3.9p1 8.RHEL4.17.1 x86_64
openssh-server 3.9p1 8.RHEL4.17.1 x86_64
sysreport 1.3.15 8 noarch
tzdata 2006m 3.el4 noarch

Testing package set / solving RPM inter-dependencies...
########################################
nss_ldap-226-17.x86_64.rpm: ########################## Done.
openssh-3.9p1-8.RHEL4.17.1. ########################## Done.
openssh-clients-3.9p1-8.RHE ########################## Done.
openssh-server-3.9p1-8.RHEL ########################## Done.
sysreport-1.3.15-8.noarch.r ########################## Done.
tzdata-2006m-3.el4.noarch.r ########################## Done.
Preparing ########################################### [100%]

Repackaging...
nss_ldap ########################################### [100%]
openssh ########################################### [100%]
openssh-clients ########################################### [100%]
openssh-server ########################################### [100%]
sysreport ########################################### [100%]
tzdata ########################################### [100%]

Installing...
1:openssh ########################################### [100%]
2:nss_ldap ########################################### [100%]
3:openssh-clients ########################################### [100%]
4:openssh-server ########################################### [100%]
5:sysreport ########################################### [100%]
6:tzdata ########################################### [100%]

If you then list the /var/spool/repackage directory, you see the old versions of the RPM's that have been "repackaged."

$ ls
nss_ldap-226-13.x86_64.rpm
openssh-3.9p1-8.RHEL4.17.x86_64.rpm
openssh-clients-3.9p1-8.RHEL4.17.x86_64.rpm
openssh-server-3.9p1-8.RHEL4.17.x86_64.rpm
sysreport-1.3.15-6.noarch.rpm
tzdata-2006m-2.el4.noarch.rpm

To list the known rollback targets:

$ up2date --list-rollbacks
install time: Sat Dec 2 05:22:49 2006 tid:1164997369
[-] nss_ldap-226-13:
[-] openssh-3.9p1-8.RHEL4.17:
[-] openssh-clients-3.9p1-8.RHEL4.17:
[-] openssh-server-3.9p1-8.RHEL4.17:
[-] sysreport-1.3.15-6:
[-] tzdata-2006m-2.el4:
[+] openssh-clients-3.9p1-8.RHEL4.17.1:
[+] nss_ldap-226-17:
[+] openssh-server-3.9p1-8.RHEL4.17.1:
[+] tzdata-2006m-3.el4:
[+] openssh-3.9p1-8.RHEL4.17.1:
[+] sysreport-1.3.15-8:

The entries with plus signs are the currently-installed versions. The entries with negative signs are the older versions that were just replaced. Note that the tid is also displayed.

To roll back this RPM transaction, use the --rollback option followed by the rollback target. The rollback target can be an actual date or a tid.