line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sys::RevoBackup::Cmd::Command::run; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Sys::RevoBackup::Cmd::Command::run::VERSION = '0.27'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
2256
|
$Sys::RevoBackup::Cmd::Command::run::AUTHORITY = 'cpan:TEX'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: run revobackup |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
115
|
use 5.010_000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
11
|
1
|
|
|
1
|
|
7
|
use mro 'c3'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
12
|
1
|
|
|
1
|
|
28
|
use feature ':5.10'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
114
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
567
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use namespace::autoclean; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# use IO::Handle; |
18
|
|
|
|
|
|
|
# use autodie; |
19
|
|
|
|
|
|
|
# use MooseX::Params::Validate; |
20
|
|
|
|
|
|
|
# use Carp; |
21
|
|
|
|
|
|
|
# use English qw( -no_match_vars ); |
22
|
|
|
|
|
|
|
# use Try::Tiny; |
23
|
|
|
|
|
|
|
use Linux::Pidfile; |
24
|
|
|
|
|
|
|
use Sys::RevoBackup; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# extends ... |
27
|
|
|
|
|
|
|
extends 'Sys::RevoBackup::Cmd::Command'; |
28
|
|
|
|
|
|
|
# has ... |
29
|
|
|
|
|
|
|
has '_pidfile' => ( |
30
|
|
|
|
|
|
|
'is' => 'ro', |
31
|
|
|
|
|
|
|
'isa' => 'Linux::Pidfile', |
32
|
|
|
|
|
|
|
'lazy' => 1, |
33
|
|
|
|
|
|
|
'builder' => '_init_pidfile', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'job' => ( |
37
|
|
|
|
|
|
|
'is' => 'ro', |
38
|
|
|
|
|
|
|
'isa' => 'Str', |
39
|
|
|
|
|
|
|
'default' => '', |
40
|
|
|
|
|
|
|
'traits' => [qw(Getopt)], |
41
|
|
|
|
|
|
|
'cmd_aliases' => 'j', |
42
|
|
|
|
|
|
|
'documentation' => 'Only execute this job', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
# with ... |
45
|
|
|
|
|
|
|
# initializers ... |
46
|
|
|
|
|
|
|
sub _init_pidfile { |
47
|
|
|
|
|
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $PID = Linux::Pidfile::->new({ |
50
|
|
|
|
|
|
|
'pidfile' => $self->config()->get('Revobackup::Pidfile', { Default => '/var/run/revobackup.pid', }), |
51
|
|
|
|
|
|
|
'logger' => $self->logger(), |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return $PID; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# your code here ... |
58
|
|
|
|
|
|
|
sub execute { |
59
|
|
|
|
|
|
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->_pidfile()->create() or die('Script already running.'); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $bankdir = $self->config()->get('Sys::RevoBackup::Bank'); |
64
|
|
|
|
|
|
|
if ( !$bankdir ) { |
65
|
|
|
|
|
|
|
die('Bankdir not defined. You must set Sys::RevoBackup::bank to an existing directory! Aborting!'); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
if ( !-d $bankdir ) { |
68
|
|
|
|
|
|
|
die('Bankdir ('.$bankdir.') not found. You must set Sys::RevoBackup::bank to an existing directory! Aborting!'); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $concurrency = $self->config()->get( 'Sys::RevoBackup::Concurrency', { Default => 1, } ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $Revo = Sys::RevoBackup::->new( |
74
|
|
|
|
|
|
|
{ |
75
|
|
|
|
|
|
|
'config' => $self->config(), |
76
|
|
|
|
|
|
|
'logger' => $self->logger(), |
77
|
|
|
|
|
|
|
'logfile' => $self->config()->get( 'Sys::RevoBackup::Logfile', { Default => '/tmp/revo.log' } ), |
78
|
|
|
|
|
|
|
'bank' => $bankdir, |
79
|
|
|
|
|
|
|
'concurrency' => $concurrency, |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
if($self->job()) { |
84
|
|
|
|
|
|
|
$Revo->job_filter($self->job()); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $status = $Revo->run(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$self->_pidfile()->remove(); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
return $status; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub abstract { |
95
|
|
|
|
|
|
|
return 'Make some backups'; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
no Moose; |
99
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=pod |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=encoding UTF-8 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 NAME |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Sys::RevoBackup::Cmd::Command::run - run revobackup |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 METHODS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 abstract |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Workadound. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 execute |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Run the backups. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 NAME |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Sys::RevoBackup::Cmd::Command::run - run all backup jobs |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Dominik Schulz <dominik.schulz@gauner.org> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Dominik Schulz. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
136
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |