Friday 27 June 2008

Fedora Sytem Restore

One of the good features of Microsoft Windows is the system restore tool which allows quick rollbacks to a previous state. When I was a Windows user, I had to make use of it extensively because the auto-updates always seemed to screw up something and make my system unusable. With Linux, that sort of problems are rare because the repositories are well managed. But sometimes things do tend to get messy after an update. I have had my fair share of updates gone awry, but they were minor infractions that didn't leave my system completely unusable. However, the time I spent on untangling the mess would have been better spent somewhere else.

Today by chance I came across a Linux Journal article about a little known feature of yum and rpm which allows rollbacks to previous states, just like Windows system restore does ! I have no idea why this feature is not enabled by default or why is it not more widely publicized, but who am I to argue with the collective inteligence of the wizards at RedHat and Fedora ?

Basically, to manually enable rollbacks of a certain install, the user has to repackage the old rpm so that it's state is saved. However, doing this manually for each and every package is cumbersome and error prone. Follow these steps to make this process automatic.

1. Edit /etc/yum.conf and add the line tsflags=repackage
2. Edit /etc/rpm/macros (You might need to create this file) and add
%_repackage_all_erasures 1
%_repackage_dir /repackaged

%_repackage_dir is not neccessary for the funcationality. But it's advisable to set it to a partition with lots of space, so that it doesn't eat out the disk space from the important data partitions.

To rollback to a previous state, simply run rpm with the -rollback option and the desired time.
rpm -Uvh -rollback '2 hour ago'

ONLamp blog lists several other variants to invoke rollback such as:
rpm -Uvh -rollback '8.00 am'
rpm -Uvh -rollback 'november 1'


Edit: After enabling repackaging on my Fedora 9 system, packagekit reported repackaging errors during an update. I am still trying to find a solution to get rid of the error messages while keeping repackaging instact. Proceed at your own risk.

No comments: