| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MMM::Sync::Rsync; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
5882
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
115
|
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
2235
|
|
|
5
|
|
|
|
|
|
|
our @ISA = qw(MMM::Sync); |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MMM::Sync::Rsync |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub buildcmd { |
|
14
|
1
|
|
|
1
|
1
|
5
|
my ($self) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
4
|
my @command = ('rsync'); |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
50
|
|
|
|
8
|
if ($self->{options}{rsync_defaults}) { |
|
19
|
0
|
|
|
|
|
0
|
push(@command, split(/ +/, $self->{options}{rsync_defaults})); |
|
20
|
1
|
|
|
|
|
2
|
} else { push(@command, '-aH'); } |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
50
|
|
|
|
4
|
if ($self->{options}{rsync_opts}) { |
|
23
|
0
|
|
|
|
|
0
|
push(@command, split(/ +/, $self->{options}{rsync_opts})); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
3
|
if ($self->{options}{exclude}) { |
|
27
|
0
|
|
|
|
|
0
|
foreach ( map { split( m/ /, $_ ) } $self->{options}{exclude} ) { |
|
|
0
|
|
|
|
|
0
|
|
|
28
|
0
|
|
|
|
|
0
|
push( @command, '--exclude', $_ ); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
4
|
my %mo = ( |
|
33
|
|
|
|
|
|
|
partialdir => 'partial-dir', |
|
34
|
|
|
|
|
|
|
tempdir => 'temp-dir', |
|
35
|
|
|
|
|
|
|
); |
|
36
|
3
|
50
|
0
|
|
|
6
|
push(@command, map { |
|
37
|
1
|
|
|
|
|
2
|
$self->{options}{$_} |
|
38
|
|
|
|
|
|
|
? '--' . ($mo{$_} || $_) |
|
39
|
|
|
|
|
|
|
: () |
|
40
|
|
|
|
|
|
|
} (qw(delete-after delete delete-excluded))); |
|
41
|
2
|
50
|
0
|
|
|
7
|
push(@command, map { |
|
42
|
1
|
|
|
|
|
2
|
$self->{options}{$_} |
|
43
|
|
|
|
|
|
|
? ('--' . ($mo{$_} || $_), $self->{options}{$_}) |
|
44
|
|
|
|
|
|
|
: () |
|
45
|
|
|
|
|
|
|
} (qw(partialdir tempdir)) |
|
46
|
|
|
|
|
|
|
); |
|
47
|
1
|
50
|
|
|
|
4
|
push(@command, '--partial') if ($self->{options}{partialdir}); |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
50
|
|
|
|
3
|
push(@command, '-e', 'ssh') if ($self->{options}{use_ssh}); |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
2
|
push( @command, |
|
52
|
|
|
|
|
|
|
$self->{source}, |
|
53
|
|
|
|
|
|
|
$self->{dest} |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
50
|
|
|
14
|
$ENV{RSYNC_PASSWORD} = $self->{options}{password} || '-'; # Avoid passwd prompt |
|
57
|
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
5
|
return @command; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _analyze_output { |
|
62
|
0
|
|
|
0
|
|
|
my ($self, $src, $line) = @_; |
|
63
|
0
|
0
|
|
|
|
|
if ($src eq 'STDERR') { |
|
|
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $line; |
|
65
|
|
|
|
|
|
|
} elsif ($line =~ /vanished|error|permission denied/i) { |
|
66
|
0
|
|
|
|
|
|
return $line |
|
67
|
|
|
|
|
|
|
} else { |
|
68
|
0
|
|
|
|
|
|
return; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _exitcode { |
|
73
|
0
|
|
|
0
|
|
|
my ($self, $exitstatus) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
return 0 if (! $exitstatus); |
|
76
|
|
|
|
|
|
|
# Handle system exit code |
|
77
|
|
|
|
|
|
|
# if (grep { ($? & 127) == $_ } ()) { |
|
78
|
|
|
|
|
|
|
# } |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Rsync exit code - no way to retry |
|
81
|
0
|
0
|
|
|
|
|
if ( |
|
82
|
0
|
|
|
|
|
|
grep { ( $exitstatus ) == $_ } ( |
|
83
|
|
|
|
|
|
|
1, # Syntax or usage error |
|
84
|
|
|
|
|
|
|
2, # Protocol incompatibility |
|
85
|
|
|
|
|
|
|
20, # SIGUSR1 ou SIGINT reçu |
|
86
|
|
|
|
|
|
|
) |
|
87
|
|
|
|
|
|
|
) |
|
88
|
|
|
|
|
|
|
{ |
|
89
|
0
|
|
|
|
|
|
return ( 2 ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# This is not a failure, but normal state |
|
93
|
0
|
0
|
|
|
|
|
if ( |
|
94
|
0
|
|
|
|
|
|
grep { ( $exitstatus ) == $_ } ( |
|
95
|
|
|
|
|
|
|
25, # The --max-delete limit stopped deletions |
|
96
|
|
|
|
|
|
|
) |
|
97
|
|
|
|
|
|
|
) |
|
98
|
|
|
|
|
|
|
{ |
|
99
|
0
|
|
|
|
|
|
return ( 0 ); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
0
|
|
|
|
|
|
return ( 1 ); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |