27

I have one machine setup with the apps I need, and I'd like to install the same on a new Ubuntu box.

Is there a script that will list all the installed apps, so that I can diff between the boxes and so add the missing items?

Thanks in advance, Chris

9 Answers 9

18

Aswell as the dpkg tricks mentioned by pjz, you may also want to look at etckeeper (tutorial ) - an app that puts your /etc/* under version control, making it easier to find any changes you've done and replicate them to other servers.

Also, for a shorter list than that produced by pjz's method, you can use

$ deborphan -a --no-show-section > /tmp/mypackagelist

This will give you a list of packages that will install all the other packages you require as dependencies. Can be useful if you actually want to look through the list. (dpkg --get-selections will produce a loooong list). In addition the list is short enough that you could add newlines and comment out entries with '#'. Then when installing the extra packages you can do

$ grep -v '#' /tmp/mypackagelist | xargs apt-get install -y

This way, if there are some packages you only want to install on some machines, you don't have to delete them from the package list altogether.

2
  • etckeeper looks really interesting (+1).
    – jkp
    Apr 30, 2009 at 17:30
  • "you may also want to look at etckeeper (tutorial ) - an app that puts your /etc/* under version control" - is that enough to keep all packages the same from one machine to another? Or is there a similar tool which can actually just reinstall all packages from one system to another? Aug 4, 2022 at 11:15
17
dpkg --get-selections >/tmp/mypackagelist

should do the trick. Then, after making sure that your /etc/apt/sources.list on the new machine has the same set of entries as on the old, copy mypackagelist over to the new machine and do:

cat mypackagelist | xargs apt-get -y install 

and you should be good to go.

Note that the dpkg --get-selections line is also good info to put into your /etc/dir ocassionally - it means you don't have to bother to back up /bin/ and /usr/bin/ and such because you know what packages are on the system.

1
  • Yes, Jeff, but how about the modifications to the configuration files? how about the dpkg-reconfigure options? how about hostnames... users, shares, mounts... See my response about dd bellow
    – elcuco
    Jul 18, 2009 at 10:01
2

Ubuntu Forums has a good answer

  1. On the old machine: $ dpkg --get-selections > installed-software
    • This gets your list of installed apps
  2. On the new machine: $ dpkg --set-selections
    • This sets the new machine to install the packages not currently installed on the new machine.
    • It might be interesting to see if the new machine has some packages not installed on the old machine, so you could find the dpkg --get-selections> command on the new machine, and then use diff to compare the output files from both.
  3. Finally, on the new machine: $ dselect and the packages will be installed.

Some additional links from the forums discussion:

  1. Don't forget your gpg keys (from the same thread)
  2. How to install all the desired packages and uninstall all the undesired packages
2

The better dpkg commands may be [original machine]

dpkg --get-selections | grep -v deinstall > packages_list

then when installing [new machine; after transferring the packages_list]

sudo dpkg --set-selections < packages_list
sudo apt-get -u dselect-upgrade
1

If you're not a CLI fan (although you really should be), you can use the Synaptic package manager to save the image of the installed packages, and use that file (again through Synaptic) to load the new machine. Under the file/save markings option, there is a checkbox called "save full state".

1
  • I think this was the method Cory found
    – jbdavid
    Jun 2, 2009 at 18:22
1

Why aren't you just clonning the machine using dd?

1
  • 1
    This. Just clone the machine and change the name, it's by far the fastest way of doing it.
    – pjc50
    Jul 17, 2009 at 16:46
1

There is a tool called ReMasterSys that can do it for you. see http://geekconnection.org/remastersys/

I hope that will be of use.

1

Using FSArchiver to replicate the machines is perfectly acceptable. Otherwise, here are useful pairs of commands, the first half of which you can also add to your backup cron:

debconf-get-selections
debconf-set-selections

~

aptitude-create-state-bundle
aptitude-run-state-bundle --unpack

~

dpkg --get-selections
dpkg --clear-selections; dpkg --set-selections

Locations you should replicate are /etc and /var. The above commands manipulate a few files in /var directly, and some conffiles in /etc indirectly via debconf. You will get the same effect by just replicating those subtrees and running aptitude.

0

I guess Docker would be the way to do this now - define the requirements in a Dockerfile - you can then run it on any Docker host.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .