Syncing apt-get installations between multiple computers

7,068

Solution 1

You could use puppet to create configuration files specifying which packages should be installed, and you could use Dropbox rather than a puppetmaster server to synchronise the puppet config between machines, plus a cron job to periodically run puppet and implement any config changes.

Solution 2

I don't know if there is a better way (there probably is), but depending on the scale you need, you could use aptitude's search feature for part of the machinery. It lets you search for packages matching a pattern. So, aptitude search '~i' gives you all installed packages

We need to go a step further, though. The packages manager likes to know which packages were directly requested by you and which ones were just pulled in because of other packages. Without that information, ugly stuff can happen. So, we can expand on that search pattern to select packages that are not automatically installed: aptitude search '!~M ~i'

The search feature is covered in some detail in Aptitude's reference manual.

Now, you have your list of packages to install. You can format the output as necessary by passing the -F flag to that command, like -F '%p' to get a list with just package names.


For example, you could run this on machine 1:

aptitude -F "%c %p" --disable-columns search '!~M ~i' | awk -F " " '{ print "apt-get -y install " $2 }' > aptshell.sh

Then copy the newly created aptshell.sh file over to machine 2 and and use this command on machine 2 to run it there:

sudo sh aptshell.sh

Then repeat the process, with the original machine 2 as the new machine 1, and the original machine 1 as the new machine 2. Now each machine has all the packages that were formerly only on the other.

Solution 3

Ubuntu Software Center has a feature for syncing installed packages among multiple computers. It uses your Ubuntu One account for saving packages. Just select File > Sync Between Computers... and login with your Ubuntu One account.

Syncing packages with Ubuntu Software Center

Currently it has somehow limited functionality, for example it only supports default packages (not ppas), and you must manually select which packages to install (this can be seen as a positive feature tough). For detailed instructions, see this article.

Solution 4

This is an old question, but since no one has said it, you could possibly do something with dpkg and cron. Set up a cron job that does something clever with the get-selections and set-selections commands of dpkg.

dpkg --set-selections < ~/Dropbox/selections.dpkg


dpkg --get-selections > ~/Dropbox/selections.dpkg

This isn't a proposed solution, you'll have to work out some way to make sure that the selections.dpkg gets updated whenever you make a change on either computer...

Share:
7,068

Related videos on Youtube

Chris
Author by

Chris

.

Updated on September 17, 2022

Comments

  • Chris
    Chris over 1 year

    Is there a way to synchronize my installations (and removals) between multiple PCs?

    Preferably with dropbox - since I'm already using that to keep my files in sync.

    I thought of an alias for the apt-get install and apt-get remove commands that stores the parameters to a file (one for install, one for remove) and another command that reads all the entries in the file and executes the respective command. Is this a realistic approach?

  • João Pinto
    João Pinto over 13 years
    -1 because your assumption is incorrect, the question describes a process to implement that, using a install/remove list, he is just asking if there is a realistic implementation, per the question description dropbox is just the medium used to exchange the synchronization lists
  • samaswin
    samaswin almost 11 years
    This is a great idea for a small number of machines. In a larger environment, you definitely should have a puppetmaster. Where I work we manage thousands of machines with puppet.
  • Rondo
    Rondo over 7 years
    It would great to include versions... machine 1 may have held back versions, for example and machine 2 should reflect that
  • Rondo
    Rondo over 7 years
    e.g., aptitude -F "%c %p %V" --disable-columns search '!~M ~i' | awk -F " " '{ print "apt-get -y install " $2"="$3 }' > aptshell.sh
  • Louis Gagnon
    Louis Gagnon over 3 years
    this is a nice solution, only issue is with the packages that require a specific repository, can you add a check for it?