Sunday, September 21, 2008

Reinstall your setup in a breeze

What do you like most about having a package manager handle all
your software? Arguably the top two features people most
commonly cite are the ease of installing new software and the
automatic patching, but one of my favourites is the ability to dump
your software selection to a file then read that back in later. In fact,
as a heavy user of virtual machines across multiple PCs, being
able to have a standard list of software I want installed means I
don’t ever find I’m missing a program at an inconvenient time
because each PC has the same software installed!
In APT, this magical superpower is called dpkg --get-
selections. It reads all the software you have installed, and prints
it all to the screen. For example:
dpkg --get-selections > software

That will save your installed list to a file called software. That list is
every piece of software required to reproduce the state your PC is
currently in. So, if you have a backup of your documents (such as
your /home directory), that plus this software list is all you need
to do a full backup and restore. Yes, I realise that many Windows
users think they need to back up their entire C:\ drive to be safe,
but we don’t have that problem on Linux because everything in
/bin, /sbin /usr and the like all comes through the package
manager, so we can let it do the work of remembering which files

Now, it’s one thing being able to save the list of software, but you
also need to be able to restore that list. For that you need the twin
brother of --get-selections, which is (you guessed it!)
--set-selections. This reads package data one line at a time, so you
need to pipe in the contents of pkglist like this:
dpkg --set-selections

That sets your software selections, but doesn’t actually install
anything. For that you need to run a special apt-get command
that translates as “look at the list of software we should have
i nstalled, and compare that against the software we actually have
installed, then make the necessary changes”:
apt-get dselect-upgrade

Any software listed in your selections that isn’t currently
installed will be installed now, so go and make some coffee..

No comments:

Blog Archive

About Me

Exclusion of liability Regarding StillStupid: The use you make of the guides, tips and downloads that you listed on this web site or on another website to which I refer is entirely at your own risk. In no way can I be held liable for damage or consequential damages of any kind, which occurs as a result of that use.