2

I have a full filesystem backup from my Ubuntu box, and my OS disk crashed.

Is there a way to list all installed packages (like dpkg -l does but) from the backup?

The logfiles are not an option as those aren't complete and they list installs, partial installs, and uninstalls etc.

  • BTW: If you're trying to recover the machine, and you have a full backup, you should just be able to replace the disk and restore the backup. Maybe change a UUID in /etc/fstab (etc.), re-install grub, and you're done. The machine should boot again, and work just like it did before the failure. – derobert Aug 14 '13 at 20:03
4

Yes, try the following code if it's not a image :

# chroot /path/to/root/backup_filesystem /bin/bash
# dpkg -l

even shorter :

# chroot /path/to/root/backup_filesystem /usr/bin/dpkg -l
| improve this answer | |
  • Brilliant! Should have thought of that myself. – jippie Aug 14 '13 at 15:45
  • Added a shorter version (one-liner) – Gilles Quenot Aug 14 '13 at 16:41
4

You can also do this without chroot. This can be useful if you can't run the binaries on the system for any number of reasons (corruption, partial backup, wrong architecture, security compromise...):

  1. You can tell dpkg to look at an alternate path using the --admindir flag. Just point it to /path-to-restored-files/var/lib/dpkg. I'd be wary of using this in the case of security compromise, though.

  2. You can look at the dpkg status file directly (in /var/lib/dpkg/status). It's a plain text file.

| improve this answer | |
  • Didn't know 1. was an option. That solves the problem of not wanting to mount rw the backup. – jippie Aug 14 '13 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.