releasing the trial release as stable
[rersyncrecent.git] / bin / rrr-client
blobfdfe2bfe3928c22fdcd5beaefe863bd7ff2c26c1
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Getopt::Long;
5 use Pod::Usage qw(pod2usage);
7 =head1 NAME
9 rrr-client - continously mirror recent updates
11 =head1 SYNOPSIS
13 rrr-client [options]
15 rrr-client --source some.mirror::module/ --target /some/dir/
17 =head1 OPTIONS
19 =over 8
21 =cut
23 my @opt = <<'=back' =~ /B<--(\S+)>/g;
25 =item B<--help|h>
27 Prints a brief message and exits.
29 =item B<--max-files-per-connection=i>
31 Defaults to 20000. Same as max_files_per_connection in
32 File::Rsync::Mirror::Recent
34 =item B<--password=s>
36 Password if the rsync source requires it. Can also be set by setting
37 the environment variable RSYNC_PASSWORD.
39 =item B<--rsync-timeout=i>
41 Defaults to 30. Same as C<timeout> within C<rsync_options> in
42 File::Rsync::Mirror::Recent
44 =item B<--runstatusfile=s>
46 Only needed for debugging. Path to the internally used status file.
47 Argument is passed through to the File::Rsync::Mirror::Recent object.
49 =item B<--skip-deletes!>
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.
54 =item B<--source=s>
56 Source to mirror from, including the name of the RECENT metadata file.
57 For example C<cpan-rsync.perl.org::CPAN/RECENT.recent>.
59 =item B<--target=s>
61 Destination directory for the mirror.
63 =item B<--tmpdir=s>
65 Directory for temporary files; should be on the same file system
66 partition as the C<--target> directory.
68 =item B<--user=s>
70 Username if the rsync source requires it.
72 =item B<--verbose!>
74 Defaults to false. Note: Older versions of rrr-client defaulted to
75 being verbose.
77 =item B<--verboselog=s>
79 Path to the logfile to write verbose progress information to.
81 =back
83 =head1 DESCRIPTION
85 Mirror a remote directory based on a set of RECENT* files provided by
86 the remote server.
88 =cut
90 our %Opt;
91 GetOptions
92 (\%Opt,
93 @opt,
94 ) or pod2usage(1);
96 if ($Opt{help}) {
97 pod2usage(0);
99 pod2usage(1) unless $Opt{source} and $Opt{target};
101 $ENV{RSYNC_PASSWORD} = $Opt{password} if $Opt{password};
102 $Opt{"max-files-per-connection"} ||= 20000;
103 $Opt{"rsync-timeout"} ||= 30;
104 $Opt{"skip-deletes"} ||=0;
105 $Opt{verbose} ||= 0;
107 use File::Rsync::Mirror::Recent;
108 my $rrr = File::Rsync::Mirror::Recent->new
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}) : ()),
123 ($Opt{runstatusfile} ? (runstatusfile => $Opt{runstatusfile}) : ()),
124 ($Opt{tmpdir} ? (tempdir => $Opt{tmpdir}) : ()),
125 verbose => $Opt{verbose},
126 ($Opt{verboselog} ? (verboselog => $Opt{verboselog}) : ()),
127 # _logfilefordone => "recent-rmirror-donelog.log",
130 $rrr->rmirror ( "skip-deletes" => $Opt{"skip-deletes"}, loop => 1 );