Net-CascadeCopy
view release on metacpan or search on metacpan
die "Nothing to do! No command, scp, or rsync options specified\n";
}
if ( $opt_args ) {
$options->{command_args} = $opt_args;
}
# source path
unless ( $opt_path ) {
die "Error: source path not specified";
}
unless ( -r $opt_path ) {
die "Error: source path not found: $opt_path";
}
$options->{source_path} = $opt_path;
# target path
if ( $opt_target_path ) {
$options->{target_path} = $opt_target_path;
}
else {
$options->{target_path} = $opt_path;
}
if ( $opt_ssh ) { $options->{ssh} = $opt_ssh }
if ( $opt_sshargs ) { $options->{ssh_flags} = $opt_sshargs }
if ( $opt_failures ) { $options->{max_failures} = $opt_failures }
if ( $opt_forks ) { $options->{max_forks} = $opt_forks }
my $ccp = Net::CascadeCopy->new( $options );
unless ( scalar @opt_group ) {
die "Error: no server groups specified\n";
}
for my $group ( @opt_group ) {
my ( $groupname, $members ) = split /:/, $group;
unless ( $groupname && $members ) {
die "Error: format of group param is group:server1,server2,...\n";
}
my @servers = split /[,\s]/, $members;
$ccp->add_group( $groupname, \@servers );
}
$ccp->transfer();
__END__
=head1 NAME
ccp - cascading copy
=head1 SYNOPSIS
# cascade copy file.gz using scp to four servers
ccp -s -f /local/file.gz -g production:server1,server2,server3,server4
# rsync /some/directory to a total of 10 servers in two datacenters
ccp -r -f /some/directory -g dc1:s1,s2,s3,s4,s5 -g dc2:s6,s7,s8,s9,s10
# log output of each child to ccp.sourcehost.targethost.log
ccp -s -l -f /local/file.gz -g production:server1,server2,server3,server4
# custom rsync options
ccp -c "/path/to/rsync" -a "-rav --checksum --delete" -f /some/directory -g prod:srv1,srv2,srv3,srv4
# sync to 10 servers, use shell brace expansion to build server names
ccp -s -f /local/file.gz -g "production:`echo server{1,2,3,4,5,6,7,8,9,10}`"
# similar to previous, but with zsh brace expansion shortcut
ccp -s -f /local/file.gz -g "production:`echo server{01..10}`"
# help
ccp
ccp --help
=head1 DESCRIPTION
Rapidly copy (rsync/scp/...) files to many servers servers in
multiple locations using Net::CascadeCopy.
=head2 taken from Net::CascadeCopy:
=over 2
This module implements a scalable method of propagating files to a
large number of servers in one or more locations via rsync or scp.
A frequent solution to distributing a file or directory to a large
number of servers is to copy it from a central file server to all
other servers. To speed this up, multiple file servers may be used,
or files may be copied in parallel until the inevitable bottleneck in
network/disk/cpu is reached. These approaches run in O(n) time.
This module and the included script, ccp, take a much more efficient
approach that is O(log n). Once the file(s) are been copied to a
remote server, that server will be promoted to be used as source
server for copying to remaining servers. Thus, the rate of transfer
increases exponentially rather than linearly. Needless to say, when
transferring files to a large number of remote servers (e.g. over 40),
this can make a ginormous difference.
Servers can be specified in groups (e.g. datacenter) to prevent
copying across groups. This maximizes the number of transfers done
over a local high-speed connection (LAN) while minimizing the number
of transfers over the WAN.
=back
=head2 ARGUMENTS
The following options are supported by this command:
=over 8
( run in 0.594 second using v1.01-cache-2.11-cpan-39bf76dae61 )