4

I'm working with backups at the moment and instead of backing up the full disks it would be much more efficient for me just to backup the configuration of the system. So for the perl-section of things I would like to have a way to list installed modules and later reinstall those modules if needed.

I read How do I get a list of installed CPAN modules? about how to get the list and when reading perldoc -l install I found this:

You can also use "cpan"'s "-a" switch to create an autobundle file that "CPAN.pm" understands and can use to re-install every module:

$ cpan -a

So I run cpan -aand the last two rows of the output is:

Wrote bundle file
    /home/ulf/.cpan/Bundle/Snapshot_2017_11_30_01.pm

And yes the file exists, but how do I use it to "re-install every module" on another host?

Note: I my have some preconceptions about this after working with requirement-files in pip so please bear with me.

UlfR
  • 4,175
  • 29
  • 45
  • 1
    Have you looked into the file? – simbabque Nov 30 '17 at 12:54
  • Are you trying to replication the configuration of Machine_A onto Machine_B? If so, you may wish to look at a provisioning utility like chef, ansible, pupper, or salt. This can make building new boxes simple and easy. – SparkeyG Nov 30 '17 at 19:04

1 Answers1

7

If you open that bundle file with a text editor or perldoc, you'll get instructions.

=head1 SYNOPSIS

perl -MCPAN -e 'install Bundle::Snapshot_2017_11_30_00'
simbabque
  • 53,749
  • 8
  • 73
  • 136
  • Ok. I had a looked at it, but as a perl- newbie it was not as obvious to me as it should have been. Thanks! – UlfR Nov 30 '17 at 13:01
  • @UlfR no problem. I just wonder _how_ that works. It seems it's going to read parse the POD, as there is no more code in there. – simbabque Nov 30 '17 at 14:57
  • After moving the file to another host and trying to run it, it's not obvious where to put it either. But after putting it in my `.cpan/Bundle` directory it worked nice and clean. – UlfR Nov 30 '17 at 15:01
  • 1
    You might need to use `-I.` (`perl -I. -MCPAN ...`) for `cpan` to locate the generated module (bundle). ("`-I.`" is dash, uppercase "i", period) – ikegami May 14 '20 at 21:31