-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleModule.pm
More file actions
47 lines (40 loc) · 1.37 KB
/
ExampleModule.pm
File metadata and controls
47 lines (40 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package examples::ExampleModule;
use strict;
use Backup::Main;
sub new {
my ($class, %args) = @_;
my $self = \%args;
bless $self, $class;
$self->{error} = 0;
return $self;
}
sub backup {
my $self = shift;
# Type tells the type of the backup: hourly, daily, weekly, monthly
my $type = shift;
my @RC = ();
my $file = Backup::Main::tempname($self->{config}).'.txt';
my $rc = 0;
# Make sure you do not produce a backup when dry-run is active
if (!$self->{config}->{dryRun}) {
$rc = system('echo "Hello World" >'.$file);
} else {
# In dry-run tell what you would do
$self->{log}->debug('Hello World debug file created');
}
if ($rc) {
# Always log an error
$self->{log}->error('Cannot create file: '.$file);
} else {
# Return value:
# 'name' the name of the backup
# 'filename' the file that contains the backup (temporary file, will be deleted)
# 'noSubDir' 1 when any sub directory in backup paths shall be flattened (Default: 0)
# 'targetDir' a sub directory structure to be used before appending the sub structure and path (optional)
# 'needsCompression' whether a compression shall be run on the file
push(@RC, {'name' => 'hello-world', 'filename' => $file, 'targetDir' => 'my-structure', 'noSubDir' => 1, 'needsCompression' => 1});
}
# Return all backup file descriptions produced
return @RC;
}
1;