Tuesday, November 23, 2010

Rollback application deployments with yum and RPM

In many cases, you will require to have a software repository or YUM repo set up on your network so you can have package management on your Linux network. The regular process is to update the new package on the new environment, test it or rollback the changes.

Using yum in combination with RPMs as package management tool is a great strategy since consistency and best practices can be applied. When a package is updated via YUM , several RPMs packages can be installed or a single package can be updated using the option –U with rpm.

#yum update


#rpm –Uvh foo.rpm

If you enable the repackaging option , every time you install an update the old package is sent to /var/spool/repackage dir on RPM form. With RPMs , you will need to use the option –-repackage:

# rpm -Uvh --repackage foo.rpm

With YUM, you can enable it on /etc/yum.conf adding the following line:


and /etc/rpm/macros.up2date  file needs to have the following line:

%_repackage_all_erasures 1

Finally, if you require to rollback changes you  will have to use the rpm command.

# rpm -Uvh --rollback '2 hours ago'

Restore will be based on packages 2 hours ago.

I hope you enjoy it.