[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Recovering dpkg database



On Sun, Apr 22, 2001 at 12:07:37AM +0200, Klaus Reimer wrote:
> My harddisk containing /var has crashed (and I am a fool without a backup). I 
> was able to recover /var/lib/dpkg/status but all other files in /var/lib/dpkg 
> except some files from /var/lib/dpkg/info are gone. Is there any way to 
> reconstruct all other files and directories (alternatives, info, diversions) 
> without reinstalling all packages?

The fact that you were able to recover status is an amazing feat in and of
itself.  It greatly simplifies matters as you at least know what is
installed.

First thing you must do in order to fix dpkg is this:

# apt-get update
# apt-cache dumpavail > avail
# dpkg --update-avail avail

You'll also need to recreate the dpkg directory structure, the contents
file on the archive will help you do that.

From then on (sorry, I know of no other way) you will simply have to get a
list of installed packages (dpkg --get-selections, you can use cut or sed
and grep or something to cut the list down to just the ones you want) and
feed the result to apt-get install..  If you do it cleverly, you can do it
on one cmdline.

Expect that you'll have to rerun it a few times.  The popularity of apt
has caused many maintainers to become lax in their dependencies since apt
will usually figure it out if you rerun it a few times.  The whole point
of apt's resolver was to make that no longer necessary, but that's another
rant for another week.

You literally must reinstall the packages to rebuild the database or apt
will not know what files are installed (rebuildable with the contents file
and a good script or two) or the pre and post scripts, debconf
information, etc..


Just in case you need it said:  BACKUP BACKUP BACKUP!  I have ... uh, 1082
packages installed here personally and together they total enough space
that rebuilding the database by reinstalling the packages would be a very
painful experience.  In fact, it happened once (thank you ext2 and DRI, I
much appreciated that..) and as the system was recently installed I had no
backup yet.  It took me all night on a DSL line, so I pity anyone with
just a modem.

-- 
Joseph Carter <knghtbrd@debian.org>                Free software developer

The less you know about computers the more you want Microsoft!
        -- Microsoft ad campaign, circa 1996

(Proof that Microsoft's advertising _isn't_ dishonest!)

Attachment: pgp_SSSQ3o8Wx.pgp
Description: PGP signature


Reply to: