The Problem
If you plan to migrate your Ubuntu machine from one hardware to another then you can follow the following approach:
- Perform a complete backup your home directory
- Extract the list of manually installed packages
- Set up a new vanilla Ubuntu on the same or another hardware
- Restore the contents of your home directory
- Re-install all missing packages
Now - where is the problem ? ... If you don't have a list of your previously installed packages, then it is not possible to use the new box as you have used the old ones - just because some of the programs that you are used to are missing.
The Solution
The solution is (as outlined above) to have a list of packages which were installed on the old computer. Forunately it is a one-liner to get this list:
$$ comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
This code snippet works by fetching the list of manually installed packages by getting a list of packages installed right after a fresh install. Afterwards, this list is compared to the list of currently installed packages. The difference between these lists is the manually installed packages.