install the same debian packages on another system

Solution 1:

To backup:

sudo dpkg --get-selections > /tmp/dpkglist.txt

To Restore:

sudo dpkg --set-selections < /tmp/dpkglist.txt
sudo apt-get -y update
sudo apt-get dselect-upgrade

Also see this question for additional options and info: Ubuntu, how to setup a new machine like an existing one

I have the above running in a daily cronjob that checks the dpgklist into SVN as part of our server inventory. This will allow you to keep a reasonable accurate inventory of installed packages across your servers and its easy to do a quick side-by-side diff to see if a server is missing a particular package.

Solution 2:

aptitude also satisfies this usecase, and it preserves information about "automatically installed" packages that other methods do not. Run the following on the reference machine:

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

Copy package_list to the other machine and run

xargs aptitude --schedule-only install < package_list; aptitude install;