Replicating Packages on a new Debian/Ubuntu install
For a variety of reasons, you may wish to upgrade your Debian/Ubuntu or similar system without going through the normal process of a distribution update. Perhaps you are, for example, moving to entirely new hardware. Obviously you want to keep the data in your home directory; but you may also wish to keep the various packages you have previously downloaded. The following is some simple steps to make your life easier.
Firstly, make sure you have etckeeper installed. It checks
/etc into a git repository that is local to the machine, which can be very handy.
Secondly, create a list of all currently installed programs by establishing yourself as root (use
su -s rather than
dpkg --get-selections | grep -v deinstall > mypackages in your home directory.
Thirdly, backup your home directory. If you've been doing this regularly,
rsync is the obvious choice, otherwise
rsync -a -e ssh /home/lev email@example.com:/home/lev/backup/. Check your backup to ensure that the text-file
mypackages is there.
Finally, once you've installed your new system, you can replicate the packages on the new system with the following commands from the home directory:
# sudo apt-get update
# sudo dpkg --set-selections # sudo apt-get -u dselect-upgrade
Replicating can also have other uses as John Ferlito discovered. In this case, after deleting some packages from
/usr/lib, John used the fact that his
locate command had not updated its database. By running locate and redirecting the output to a file, he was able to establish what packages the database were installed prior to the fateful command. By running the command after doing an
updatedb he was able to determine what was actually left. By running a
diff between the two he could generate a list of missing packages. Nice work!