| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Pod::Usage qw(pod2usage); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | rrr-client - continously mirror recent updates | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | rrr-client [options] | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | rrr-client --source some.mirror::module/ --target /some/dir/ | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 OPTIONS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =over 8 | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =cut | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | my @opt = <<'=back' =~ /B<--(\S+)>/g; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =item B<--help|h> | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | Prints a brief message and exits. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =item B<--max-files-per-connection=i> | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Defaults to 20000. Same as max_files_per_connection in | ||||||||||||||||||||||||||||
| 32 | File::Rsync::Mirror::Recent | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =item B<--password=s> | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | Password if the rsync source requires it. Can also be set by setting | ||||||||||||||||||||||||||||
| 37 | the environment variable RSYNC_PASSWORD. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =item B<--rsync-timeout=i> | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | Defaults to 30. Same as C<timeout> within C<rsync_options> in | ||||||||||||||||||||||||||||
| 42 | File::Rsync::Mirror::Recent | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =item B<--runstatusfile=s> | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Only needed for debugging. Path to the internally used status file. | ||||||||||||||||||||||||||||
| 47 | Argument is passed through to the File::Rsync::Mirror::Recent object. | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =item B<--skip-deletes!> | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Defaults to false. If true, skips all delete events in the index files | ||||||||||||||||||||||||||||
| 52 | which means no files are being deleted that have been deleted upstream. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =item B<--source=s> | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | Source to mirror from, including the name of the RECENT metadata file. | ||||||||||||||||||||||||||||
| 57 | For example C<cpan-rsync.perl.org::CPAN/RECENT.recent>. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =item B<--target=s> | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Destination directory for the mirror. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =item B<--tmpdir=s> | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Directory for temporary files; should be on the same file system | ||||||||||||||||||||||||||||
| 66 | partition as the C<--target> directory. | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =item B<--user=s> | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Username if the rsync source requires it. | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =item B<--verbose!> | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Defaults to false. Note: Older versions of rrr-client defaulted to | ||||||||||||||||||||||||||||
| 75 | being verbose. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =item B<--verboselog=s> | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Path to the logfile to write verbose progress information to. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =back | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Mirror a remote directory based on a set of RECENT* files provided by | ||||||||||||||||||||||||||||
| 86 | the remote server. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 1 | our %Opt; | |||||||||||||||||||||||||||
| 91 | 1 | ▶ | GetOptions | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | (\%Opt, | ||||||||||||||||||||||||||||
| 93 | @opt, | ||||||||||||||||||||||||||||
| 94 | ) or pod2usage(1); | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 1 | ▶ | if ($Opt{help}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 1 | pod2usage(0); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | pod2usage(1) unless $Opt{source} and $Opt{target}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$main::Opt{"source"} and $main::Opt{"target"}
MC/DC0%0/2
$main::Opt{"source"} and $main::Opt{"target"}
$main::Opt{"source"}
$main::Opt{"target"}
Truth table0%0/3
A and B
A= $main::Opt{"source"}B= $main::Opt{"target"}
| |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $ENV{RSYNC_PASSWORD} = $Opt{password} if $Opt{password}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $Opt{"max-files-per-connection"} ||= 20000; | ||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"max-files-per-connection"} ||= 20000
MC/DC0%0/1
$main::Opt{"max-files-per-connection"} ||= 20000
$main::Opt{"max-files-per-connection"}
Truth table0%0/2
A
A= $main::Opt{"max-files-per-connection"}
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $Opt{"rsync-timeout"} ||= 30; | ||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"rsync-timeout"} ||= 30
MC/DC0%0/1
$main::Opt{"rsync-timeout"} ||= 30
$main::Opt{"rsync-timeout"}
Truth table0%0/2
A
A= $main::Opt{"rsync-timeout"}
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $Opt{"skip-deletes"} ||=0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"skip-deletes"} ||= 0
MC/DC0%0/1
$main::Opt{"skip-deletes"} ||= 0
$main::Opt{"skip-deletes"}
Truth table0%0/2
A
A= $main::Opt{"skip-deletes"}
| |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $Opt{verbose} ||= 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"verbose"} ||= 0
MC/DC0%0/1
$main::Opt{"verbose"} ||= 0
$main::Opt{"verbose"}
Truth table0%0/2
A
A= $main::Opt{"verbose"}
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | ▶ | use File::Rsync::Mirror::Recent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 108 | my $rrr = File::Rsync::Mirror::Recent->new | ||||||||||||||||||||||||||||
| 109 | ( | ||||||||||||||||||||||||||||
| 110 | ignore_link_stat_errors => 1, | ||||||||||||||||||||||||||||
| 111 | localroot => $Opt{target}, | ||||||||||||||||||||||||||||
| 112 | max_files_per_connection => $Opt{"max-files-per-connection"}, | ||||||||||||||||||||||||||||
| 113 | remote => ($Opt{user} ? $Opt{user} . '@' : '') . $Opt{source}, | ||||||||||||||||||||||||||||
| 114 | rsync_options => { | ||||||||||||||||||||||||||||
| 115 | compress => 1, | ||||||||||||||||||||||||||||
| 116 | links => 1, | ||||||||||||||||||||||||||||
| 117 | 'safe-links' => 1, | ||||||||||||||||||||||||||||
| 118 | times => 1, | ||||||||||||||||||||||||||||
| 119 | checksum => 0, | ||||||||||||||||||||||||||||
| 120 | timeout => $Opt{"rsync-timeout"}, | ||||||||||||||||||||||||||||
| 121 | ($Opt{tmpdir} ? ('temp-dir' => $Opt{tmpdir}) : ()), | ||||||||||||||||||||||||||||
| 122 | }, | ||||||||||||||||||||||||||||
| 123 | ($Opt{runstatusfile} ? (runstatusfile => $Opt{runstatusfile}) : ()), | ||||||||||||||||||||||||||||
| 124 | ($Opt{tmpdir} ? (tempdir => $Opt{tmpdir}) : ()), | ||||||||||||||||||||||||||||
| 125 | verbose => $Opt{verbose}, | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | ($Opt{verboselog} ? (verboselog => $Opt{verboselog}) : ()), | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 127 | # _logfilefordone => "recent-rmirror-donelog.log", | ||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | $rrr->rmirror ( "skip-deletes" => $Opt{"skip-deletes"}, loop => 1 ); | |||||||||||||||||||||||||||