Administration

Synchronizing CPAN modules between different hosts

For the second time this year I’ve taken on the task of setting up new servers as replacement for our old ones. Since the old ones run Debian and the freshly acquired ones have Ubuntu Server preinstalled on them, synchronizing packages between them was a breeze.

However, one of the old servers had quite a few Perl modules installed via CPAN and some of our applications that we were migrating to the new servers depend heavily on these little suckers. Naturally, CPAN packages are handled from the CPAN utilities and not the system’s local package manager, which left me with a clean Perl install and none of the required modules once the new server finished installing all the Ubuntu packages…

After a quick Google-fu workout I stumbled across the ingenious “autobundle” feature for making bundled CPAN repository snapshots. This dumps all the installed packages and their version numbers in a snapshot file which is easily imported through CPAN on another host.

Here’s how!

# perl -MCPAN -e ‘autobundle’

Wow, that was fast! A quick look in our ~/.cpan directory shows us a newly created directory called “Bundle”, which is an installable CPAN package. In that directory we got our snapshot module, named by today’s date and the time we made the snapshot for easy archiving and separating different snapshots depending on when they were done.

To install it, just transfer the “Bundle” directory to your new server (along with the snapshot modules) and install it as you would install any other CPAN package or module:

# perl -MCPAN -e ‘install Bundle::Snapshot_2009_04_30_00′

This also makes a great feature for backing up your CPAN library state!

Now, if I only could get CPAN to automatically follow all dependencies without asking me for permission… Any ideas? ;-)

UPDATE: I found another thread from the hackers over at perlmonks.org with tips on how to get your autobundle ordered by dependency, so that CPAN doesn’t bug you about needed packages even though they are included later on in the list. Check it out!

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields