line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sys::RevoBackup::Cmd::Command::cleanup; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Sys::RevoBackup::Cmd::Command::cleanup::VERSION = '0.27'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
12572
|
$Sys::RevoBackup::Cmd::Command::cleanup::AUTHORITY = 'cpan:TEX'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
# ABSTRACT: cleanup command |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
37
|
use 5.010_000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
11
|
1
|
|
|
1
|
|
5
|
use mro 'c3'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
12
|
1
|
|
|
1
|
|
38
|
use feature ':5.10'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
121
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
539
|
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 Sys::RevoBackup; |
24
|
|
|
|
|
|
|
use Sys::RotateBackup; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# extends ... |
27
|
|
|
|
|
|
|
extends 'Sys::RevoBackup::Cmd::Command'; |
28
|
|
|
|
|
|
|
# has ... |
29
|
|
|
|
|
|
|
# with ... |
30
|
|
|
|
|
|
|
# initializers ... |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# your code here ... |
33
|
|
|
|
|
|
|
sub execute { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $Revo = Sys::RevoBackup::->new({ |
37
|
|
|
|
|
|
|
'config' => $self->config(), |
38
|
|
|
|
|
|
|
'logger' => $self->logger(), |
39
|
|
|
|
|
|
|
'logfile' => $self->config()->get( 'Sys::RevoBackup::Logfile', { Default => '/tmp/revo.log', } ), |
40
|
|
|
|
|
|
|
'bank' => $self->config()->get('Sys::RevoBackup::Bank', { Default => '/srv/backup/revobackup', } ), |
41
|
|
|
|
|
|
|
'concurrency' => 1, |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $vault_ref = $Revo->vaults(); |
45
|
|
|
|
|
|
|
if($vault_ref && ref($vault_ref) eq 'ARRAY') { |
46
|
|
|
|
|
|
|
foreach my $vault (sort @{$vault_ref}) { |
47
|
|
|
|
|
|
|
# rotate the backups |
48
|
|
|
|
|
|
|
my $Rotor = Sys::RotateBackup::->new( |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
'logger' => $self->logger(), |
51
|
|
|
|
|
|
|
'sys' => $Revo->sys(), |
52
|
|
|
|
|
|
|
'vault' => $Revo->fs()->filename( ( $Revo->bank(), $vault ) ), |
53
|
|
|
|
|
|
|
'daily' => $self->config()->get( 'RevoBackup::Rotations::Daily', { Default => 10, } ), |
54
|
|
|
|
|
|
|
'weekly' => $self->config()->get( 'RevoBackup::Rotations::Weekly', { Default => 4, } ), |
55
|
|
|
|
|
|
|
'monthly' => $self->config()->get( 'RevoBackup::Rotations::Monthly', { Default => 12, } ), |
56
|
|
|
|
|
|
|
'yearly' => $self->config()->get( 'RevoBackup::Rotations::Yearly', { Default => 10, } ), |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
$Rotor->cleanup(); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub abstract { |
67
|
|
|
|
|
|
|
return 'Cleanup old and/or broken backups'; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
no Moose; |
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=encoding UTF-8 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Sys::RevoBackup::Cmd::Command::cleanup - cleanup command |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 METHODS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 abstract |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Workaround |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 execute |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Clean up old rotations. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Sys::RevoBackup::Cmd::Command::cleanup - Remove old/broken directories |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Dominik Schulz <dominik.schulz@gauner.org> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Dominik Schulz. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |