Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I don't know if it is common knowledge, but RPM has support for rollbacking to a previous installation after performing an upgrade (which breaks something for instance). You can pass rpm the --repackage flag to generate a bunch of RPMs of files currently installed that it is going to change. You can then afterwards say "rpm -Uvh --rollback '2 hours ago'" and rollback your machine effortlessly to as it was 2 hours ago.

My question is, has anyone found something similar in Debian-based distros?

share|improve this question
1  
BTW, the RPM rollback stuff is kinda buggy and unreliable. It has the inherent problem of the shell scripts in RPMs and the additional problem of neglect. And has been removed in RPM 4.6: rpm.org/wiki/Releases/4.6.0#Removedfeatures –  freiheit Jun 7 '09 at 18:23
add comment

3 Answers

up vote 4 down vote accepted

I don't believe that there is such an option with aptitude or apt-get. However, aptitude keeps an excellent, clear log at /var/log/aptitude.You can use that to attempt rollbacks.

How well it will go will depend on the exact situation. If you merely want to remove a few packages you've installed, it should be trivial. But if you've upgraded (either because you follow testing or unstable or because you installed a security upgrade or point-release upgrade), then things are a bit more complicated. You can check if you still have the older .deb in your cache, or you can visit Debian snapshot.

If you don't use aptitude, you can poke around in dpkg's log (at /var/log/dpkg.log), but I find that a lot less friendly to work with.

Edit Now that I look at the article, there is one thing that is somewhat similar. You can get the state of your packages by doing this sequence. First get a list of the current package state:

dpkg --get-selections "*" > my_packages-datestamp

Then later you could rollback by using that package list:

dpkg --set-selections < my_packages-datestamp
apt-get -u dselect-upgrade

I've used this method to reinstall and then have exactly the current set of packages on the machine, and it's worked well. Again, though, how well it works will depend on what packages from the previous package list are available to you - either in your cache or in your repos.

share|improve this answer
    
This doesn't set the package version number though –  Steve Schnepp Jul 20 '09 at 14:14
    
@Steve: Right, which is why I said this: "Again, though, how well it works will depend on what packages from the previous package list are available to you - either in your cache or in your repos." –  Telemachus Jul 23 '09 at 22:35
add comment

There is no such option in dpkg or any apt related tool and there's a simple reason explaining this. Installing a package is not only unpacking files but also configuring them and this is done by running the pre/post installation/removal script associated to each package.

Restoring old files is easy but undoing what the postinst scripts have done is way more difficult. In theory dpkg supports the downgrade because it gives all the necessary information to the scripts so that they can detect when they're downgraded but in practice very few package implements that support properly (and Debian doesn't support downgrades officially).

Note however that for many simple packages that have no postinst script, the downgrade works very well. apt-get and aptitude can be used to force installation of older version with syntaxes like this:

aptitude install foo/testing # Downgrade a package to testing if you run unstable
aptitude install foo=1.2-3 # Downgrade to 1.2-3 if you run a higher version

So if you keep a note of all packages installed with their version, you can in most cases restore a previous state that works. You can also find out the versions previously installed by analzing dpkg's log /var/log/dpkg.log (or aptitude's log if you use only aptitude and not apt-get).

share|improve this answer
add comment

Sadly this is not something that either dpkg or apt is able to do. Debian packages aren't really meant to be downgraded and it isn't supported or tested. There certainly is no snapshotting support.

However, having said that, you can do it by hand. If you look in /var/log/dpkg.log, you'll find the log of operations that have happened. It's a little verbose, but you should be able to get the list of previous versions of packages that have been installed. Assuming they are still available in the repositories configured in your sources.list, you should be able to do:

# apt-get install foo=1.2 bar=3.4-5

If they are not available in the repo, you might still find them in /var/cache/apt/archives/ or you may be able to find them available for download somewhere, maybe in another repository. Once you have your list of packages, you can run:

# dpkg -i foo_1.2_amd64.deb bar_3.4-5_all.deb

You should then find you're back to the versions you had installed before. You may find that somethings are not the same, like configuration.

There is a method for having snapshots using LVM, but this is not particularly quick or easy to enable on an existing install. You would probably have to reinstall the system and set up your drives to use LVM. You can then create a LVM snapshot, do the upgrade, test it and then either remove the snapshot if you're happy or roll back to that snapshot if you're not. Obviously any data written since the snapshot will be removed as well as the packages.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.