Replicating server with dpkg

This short guide illustrates how to replicate a server, in the sense of how to get the same packages installed. I have tried this on Debian 6.

Save a list of installed packages on the current machine:

cd
dpkg --get-selections > selections.txt

Now move selections.txt to the new machine.
Set package list on the new machine and install packages:

cd
dpkg --set-selections < selections.txt
apt-get update
apt-get upgrade

Installed packages can be obtained with:

aptitude search '~i'