Linux – backup list of installed packages

backupdpkglinux-mintpackage-management

I want to reinstall my linux system (specifically linux mint). I have kept important data elsewhere, so I can safely remove everything.

However, I want to do the following:

  1. save the list of packages I have installed so far
  2. after reinstall take the backup list and use it to install packages

Are there tools that can assist in doing this. I know I can use dpkg -l to get list but perhaps I only want the leafs – packages that no other depend on.

Best Answer

The problem with using dpkg --get-selections is that it does not preserve some package states such as "automatically installed". To preserve all data, you can use the aptitude front-end to backup and restore the package list:

aptitude search -F '%100p' '~i!~M' > package_list #backup

xargs aptitude --schedule-only install < package_list
aptitude install #restore
Related Question