"Repair" Debian installation

Posted by: Roger

"Repair" Debian installation - 26/02/2009 12:20

If you've been following my other posts, you'll know that I hosed my VPS, and that the restore didn't go too well. What I'd like to do now is repair it.

By that I mean: is there a command-line that I can run that takes a look at the currently-installed packages and reapplies the binaries?

It's Debian 'etch', by the way.

I've got a recent, but suspect, local backup, and a less-recent, but less-supect, local backup so I'm not too bothered about my data.
Posted by: peter

Re: "Repair" Debian installation - 26/02/2009 12:38

Code:
apt-get --reinstall install `dpkg-query -W -f '${Package}\n'`

..? Or perhaps this is the ideal time to upgrade to Lenny?

Peter
Posted by: peter

Re: "Repair" Debian installation - 26/02/2009 12:41

Oh, and I suppose "apt-get clean" first, if you also don't trust the contents of /var/cache/apt.

Peter
Posted by: Roger

Re: "Repair" Debian installation - 26/02/2009 12:42

Originally Posted By: peter
Code:
apt-get --reinstall install `dpkg-query -W -f '${Package}\n'`

..? Or perhaps this is the ideal time to upgrade to Lenny?

Peter


It was upgrading to Lenny that broke it -- the VPS hypervisor barfed...

As an aside, I came up with the following:

Code:
dpkg --get-selections | grep \\binstall\\b | cut -f1 | xargs aptitude reinstall

Posted by: Roger

Re: "Repair" Debian installation - 26/02/2009 12:54

Code:
aptitude reinstall -f `dpkg-query -W -f '${Package}\n'`
E: I wasn't able to locate a file for the <whatever> package. This might mean you need to manually fix this package.
 (due to missing arch)
<a few more of those>
E: Couldn't lock list directory..are you root?


Yes, I bloody well am. mad
Posted by: Roger

Re: "Repair" Debian installation - 26/02/2009 12:56

Bizarrely, using apt-get seems to be working. It even tells me that the missing files are missing from the FTP server. Which is useful to know.
Posted by: wfaulk

Re: "Repair" Debian installation - 26/02/2009 13:59

Maybe aptitude has trouble with multiple package names on the command line?
Posted by: Roger

Re: "Repair" Debian installation - 26/02/2009 14:10

Originally Posted By: wfaulk
Maybe aptitude has trouble with multiple package names on the command line?


Not usually, no.
Posted by: Roger

Re: "Repair" Debian installation - 26/02/2009 14:19

Originally Posted By: Roger
Bizarrely, using apt-get seems to be working. It even tells me that the missing files are missing from the FTP server. Which is useful to know.


Ah. Spoke too soon -- apt-get can't reinstall more than one thing at a time -- it thinks there are dependency cycles.

Turning the output from the dpkg-get command into a shell script seems to be working.
Posted by: Roger

Re: "Repair" Debian installation - 26/02/2009 17:15

Originally Posted By: Roger
Turning the output from the dpkg-get command into a shell script seems to be working.


Seems to have worked. Everything is now (allegedly) reinstalled. I should therefore be able to trust my binaries.

I've restored the MySQL database for my CMS (drupal). I'll do the Gallery2 ones in a moment.

I'll verify my qmail (and other) installation by checking hashes against an older backup.

What's not good is that the following...

Code:
find . -type f -exec file {} \; | grep RFC\ 822


...is returning a list of files that shouldn't be emails, such as the avatars on my website.

What a mess. frown