Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Running Debian Lenny distros :

I'm still wondering how to iso a complete distro setup "easily", but for the time being, I'd like to able to run easily and quickly a reinstall, so I added such a line in my rsync backup shells :

# Store the list of installed packages
dpkg --get-selections > $PACKAGES

Is there a better way using dpkg or another tool in order to be able to generate an automated reinstallation file from an existing system in case of failure ?

share|improve this question
up vote 3 down vote accepted

apt now tracks which packages are manually installed vs. those which are automatically installed. A manually installed package is one where you explicitly requested it to be installed. When you run apt-get install foo, then foo is marked as "manually installed". When, in order to satisfy the dependencies of foo, it also has to install bar, then bar is marked as "automatically installed". This is useful so that later, when you apt-get remove foo, the system can know that you no longer need bar either.

Your method, using dpkg --get-selections will lose this information. A better package list can be obtained by getting a list of just the manually installed packges:

aptitude search '~i!~M' -F %p

~i means "installed packages". !~M means "not automatically installed". -F %p formats the output to be package names only.

When you install packages, they often prompt you for more configuration options. This is stored in the 'debconf' database. You may want to also backup this database. This database can be backedup and restored with debconf-get-selections and debconf-set-selections which will require the debconf-utils package.

share|improve this answer
Thx, crystal clear. I'll go for it. Right after I'll have migrated to Squeeze. – hornetbzz May 17 '12 at 0:53

That looks like the easy way to me.

The more complicated and involved way is to define everything using a tool like Puppet or Chef. To that extent, I try to think of my files in one of three categories:

  • Software
    • Anything owned by an installation package
    • If I'm custom-installing something in production, it should be through a custom package
  • Configurations
    • These might overwrite package-defined configurations.
  • Data

Configurations are managed and backed up through Puppet. Software packages come from online mirrors and installation media. Data is "everything else" and ideally limited in the directories that it can show up in. That makes backups simpler, smaller, and faster and allows for easy migration to other machines or reinstallation of a system for any reason.

share|improve this answer
thx, I could install puppet from my src list, but just one question: did you install and use this on a production machine ? (as I'm reluctant to install many stuffs for admin tasks on a prod machine) – hornetbzz May 17 '12 at 0:52
Yes, I use this to manage production systems. – Jeff Ferland May 17 '12 at 2:40

Your Answer


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.