13

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?

5 Answers 5

12

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.

3
  • It would great to include versions... machine 1 may have held back versions, for example and machine 2 should reflect that
    – Rondo
    Oct 15, 2016 at 5:26
  • e.g., aptitude -F "%c %p %V" --disable-columns search '!~M ~i' | awk -F " " '{ print "apt-get -y install " $2"="$3 }' > aptshell.sh
    – Rondo
    Oct 15, 2016 at 5:34
  • this is a nice solution, only issue is with the packages that require a specific repository, can you add a check for it? Oct 9, 2020 at 4:15
7

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.

1
  • 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.
    – Ed Manet
    Aug 14, 2013 at 18:26
3

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...

2

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.

-2

You won't be able to use dropbox to sync package installs.

Synaptic does have a way to save a package download list, but I'm not sure it handles the case of "everything that's ever been installed" rather than just "these are the packages I want to download this time"

1
  • -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 Jan 10, 2011 at 16:43

You must log in to answer this question.

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