LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-13-2006, 04:37 PM   #1
jdavidow
Member
 
Registered: Sep 2004
Posts: 42

Rep: Reputation: 15
System recovery using apt/dpkg?


A month ago, I lost my boot drive on my debian box. I lost everything but /etc, /var and /home (those were on a RAID 5, the boot on a single drive that I forgot to upgrade/backup. I know.).

There was a mad dash to reinstall the system (I chose Ubuntu this time) and get everything working, and in the end it was a good exercise for me. But then I got to thinking... I have /etc, and I have /var...

Is there some way to install a basic debian-based distro, and then use dpkg data from /var and /etc to automatically 'clone' the old installation? I looked on the web for ways of doing this and I have not found any.

Thanks!

Jed
 
Old 07-13-2006, 04:52 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
On my machine, it looks like the status file is in /var/lib/dpkg/status. If I read through this the programs have package name/description/status(installed,purged,etc)/etc...

Normally, I backup my install by running dpkg --get-selections > installed.txt. This creates a file of the format
Code:
xbase-clients          install
xfonts-base           install
firestarter           deinstall
fwbuilder             purge
....
Then on another machine I can do the following
Code:
aptitude update
dselect update
dkpg --set-selections < installed.txt
apt-get dselect-upgrade
So I guess you could try to recreate that file with a script that scans the /var/lib/dpkg/status file for those installed programs...
 
Old 07-13-2006, 04:56 PM   #3
jdavidow
Member
 
Registered: Sep 2004
Posts: 42

Original Poster
Rep: Reputation: 15
Cool. So would it be as easy as running the apt-get upgrade to reinstall everything, then booting to a liveCD and copying over the /etc (and /home, /var) folders from the backup?
 
Old 07-13-2006, 04:59 PM   #4
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Quote:
Originally Posted by jdavidow
Cool. So would it be as easy as running the apt-get upgrade to reinstall everything, then booting to a liveCD and copying over the /etc (and /home, /var) folders from the backup?
Sorry, I don't understand your question.
 
Old 07-13-2006, 05:10 PM   #5
jdavidow
Member
 
Registered: Sep 2004
Posts: 42

Original Poster
Rep: Reputation: 15
So let me rephrase. Would this work?

Recovery Sequence:
1) Install minimal debian-based system with apt.
2) aptitude update
3) dselect update
4) dkpg --set-selections < installed.txt
5) apt-get dselect-upgrade
6) Reboot into a recovery disk.
7) Replace the new /etc, /var and /home with the backup versions.
8) Reboot
 
Old 07-13-2006, 05:16 PM   #6
jdavidow
Member
 
Registered: Sep 2004
Posts: 42

Original Poster
Rep: Reputation: 15
Hmm. What about versions? I know that's in the status file- but it's not in the get-selections output.
 
Old 07-13-2006, 05:17 PM   #7
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
I would say yes, as long as you already built the installed.txt file ahead of time. I'd be nervous about just replacing wholesale all of /etc and /var. But I've definitely taken specific config files from a backup /etc to replace the ones on a new install.

I guess you could always backup the new /etc, /var, and /home first. That way if you hose it up, you can just revert to the old and do it a few files at a time. As for /home, the only thing I'd be nervous about is that the file owners might have a different UID than what gets created this time...
 
Old 07-13-2006, 05:20 PM   #8
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Quote:
Originally Posted by jdavidow
Hmm. What about versions? I know that's in the status file- but it's not in the get-selections output.
I think version isn't needed because apt tracks package names and just keeps versions to compare dependencies and stuff. Most of this stuff won't be installed, so it'll say "hey, that's not installed, let's go get whatever the latest version on the server is". So I guess before you do all that stuff you should probably run a dist-upgrade on the base install to make sure you've got all the latest packages.
 
Old 07-13-2006, 05:49 PM   #9
jdavidow
Member
 
Registered: Sep 2004
Posts: 42

Original Poster
Rep: Reputation: 15
Thank You!

About the versions though: I think there could be trouble- for example, the selections dump lists both mysql-server and mysql-server-5.0. My old installation ran 4.1 (I checked, both mysql-server and mysql-server-4.1 are listed in the old status file).

Maybe I need to clean up my current installation to reference specific versions instead of the current version? Maybe I just need to understand dpkg better.
 
Old 07-13-2006, 05:54 PM   #10
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Are both marked as install or is one marked as install and one marked as deinstall/purge?

When I apt-cache search mysql on sarge, mysql-server relates to 4.0.24-10sarge1 and mysql-server-4.1 is 4.1.11a-4sarge2. Both list the other as a conflicting package. So I don't think they could both be listed as installed...
 
Old 07-13-2006, 06:50 PM   #11
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Wouldn't it be easier to just tar gzip up everything, use sfdisk to create a file that contains the partition layout, and save that on some storage media elsewhere?

Then, if your drive crashes:

1. Load up knoppix
2. Partition the drive from the partition layout file you created
3. Install a bootloader
4. Unpack everything from your compressed tarball

This way, you won't have to worry about package version mismatch or something else failing during the recovery. Just an idea.

-twantrd
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
APT/dpkg errors! /var/lib/dpkg/status bassclarinet Debian 16 12-01-2011 09:24 AM
how to manually install a package when dpkg, apt-get are broken and system wont boot. hisnumber666 Linux - Software 17 05-02-2006 11:12 AM
broken system. libc6 is missing, dpkg and apt-get not working. help!!! hisnumber666 Linux - Software 3 05-01-2006 07:20 PM
dpkg not working nor apt-get alhaidry Debian 2 08-12-2004 08:45 AM
debian apt-get dpkg eltongeoff Linux - Software 0 03-12-2003 11:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration