1

I'm trying to rebuild a Debian system from a recent backup.

All the recipes for doing this that I've found begin with a step of the form

dpkg --get-selections > package_list

This, of course, must be done on the original system, while all I have is an rsync backup on an external drive. This backup, however, includes all of /etc and most1 of /var.

Is there a convenient way to replicate/approximate the output of dpkg --get-selections from the contents of /etc and /var?


1 Excluded from the backup are /var/{tmp,run,lock}.

kjo
  • 15,339
  • 25
  • 73
  • 114

1 Answers1

6

All you need to retrieve the selections is the status file (from /var/lib/dpkg/status or one of its backups, /var/lib/dpkg.status*), and an updates directory alongside it. Then you can run

dpkg --admindir=/mnt/backup/var/lib/dpkg/ --get-selections

to retrieve the package selections.

Once you've restored the installed packages, and before you do anything else to the rebuilt system, you might want to restore /var/lib/apt/extended_states from the backup — that will restore the "automatically installed" flags.

bdsl
  • 195
  • 3
Stephen Kitt
  • 434,908