Thursday, February 7, 2008

Backup/Restore Package Selection States

I tend to install documentation packages that aptitude lists as suggested for installation. I rarely read the documentation though, which is a pity.

One of these packages - debian-reference - was upgraded today. On a whim I started going through it, and I stumbled on a solution to a problem that was nagging me for a while:

I only backup a restricted set of files, under the assumption that if I ever need to restore a system from scratch I'll simply install a new system and configure it using the restored configuration files. The problem here is that I need a way to re-install all the packages that I'm already using. I don't have a good way of doing this, and even if I had, there's the issue of configuring all these packages upon installation - a tedious if not impractical process.

Section 6.4.9 of the Debian Reference provides the solution. To backup your system package configuration, install debconf-utils and run

dpkg --get-selections "*" > myselections
debconf-get-selections > debconfsel.txt
I intend to run these commands as part of the nightly backup process.
To restore it run the following commands

dselect update
debconf-set-selections < debconfsel.txt
dpkg --set-selections < myselections
apt-get -u dselect-upgrade
(I haven't tested the latter, and I hope I don't ever need to do it...)

3 comments:

  1. Beautiful! I hope to test this sometime soon. I want to backup the Gutsy install on my eeePC before trying out some other distributions (eeeUbuntu first and foremost). I'll do a full partition backup, but I'll try this first when restoring.

    ReplyDelete
  2. One other question, before I go searching the depths of your blog: do es one of your post list the files that you backup?

    ReplyDelete
  3. Here's my bacula fileset definition. It's based on the default configuration that's shipped with the debian bacula package, plus some exclusions.

    FileSet {
    Name = machine-cycle-fileset
    Include {
    Options {
    signature = SHA1
    compression = GZIP
    Exclude = yes
    WildDir = "/home/*/.mozilla*/*/*/Cache"
    WildDir = "/home/*/.mozilla*/*/ImapMail"
    WildDir = "/home/*/.thumbnails"
    WildDir = "/home/*/.Trash"
    WildDir = "/home/*/.aMule/Incoming"
    WildDir = "/home/*/.aMule/Temp"
    WildDir = "/home/*/downloads/torrents"
    WildDir = "/home/*/dvdrip-data"
    WildDir = "/home/*/temp"
    WildDir = "/home/*/tmp"
    WildDir = "/home/*/.wine"
    WildDir = "/home/*/.ies4linux"
    WildDir = "/home/*/.cache"
    WildDir = "/home/*/.local"
    WildDir = "/home/*/.macromedia"
    }
    File = /home/zungbang
    File = /root
    File = /etc
    File = /var/www
    File = /var/lib/bacula
    }
    Exclude {
    File = /proc
    File = /tmp
    File = /.journal
    File = /.fsck
    File = /etc/selinux
    File = /etc/htdig
    File = /root/temp
    File = /root/tmp
    File = /root/.cache
    File = /root/.local
    }
    }

    ReplyDelete