-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmysqldumpbackup.pp
71 lines (67 loc) · 1.94 KB
/
mysqldumpbackup.pp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# This preset has the following params
#
# +instance+: name of instance. will be added as argument to
# mysqldumpbackup unless it is default.
# +ignore_not_running+: if true, exit silently without taking backup
# if mysql is not running.
#
# The other preset parameters are stored in a configuration file
# (/etc/default/mysqldumpbackup or /etc/default/mysqldumpbackup-$instance)
#
# This is managed by bareos::job::preset::mysqldumpbackup::config to
# do validation and defaults of parameters. Available parameters are
# documented there.
#
define bareos::job::preset::mysqldumpbackup(
$short_title,
$client_name,
$base,
$jobdef,
$fileset,
$runscript,
$sched,
$accurate,
$order,
$params,
)
{
if ($jobdef == '') {
$_jobdef = 'DefaultMySQLJob'
} else {
$_jobdef = $jobdef
}
ensure_resource('file', '/usr/local/sbin/mysqldumpbackup', {
source => 'puppet:///modules/bareos/preset/mysqldumpbackup',
mode => '0755',
owner => 'root',
group => 'root',
})
if $params['ignore_not_running'] {
$options = '-c -r'
} else {
$options = '-c'
}
if $params['instance'] {
$instance = "mysqldumpbackup-${params['instance']}"
$command = "/usr/local/sbin/mysqldumpbackup ${options} ${instance}"
} else {
$instance = 'mysqldumpbackup'
$command = "/usr/local/sbin/mysqldumpbackup ${options}"
}
ensure_resource('bareos::job::preset::mysqldumpbackup::config',
$instance,
delete($params, ['instance', 'ignore_not_running']))
@@bareos::job_definition {
$title:
client_name => $client_name,
name_suffix => $bareos::client::name_suffix,
base => $base,
jobdef => $_jobdef,
fileset => $fileset,
runscript => flatten([$runscript, [{ 'command' => $command }] ]),
sched => $sched,
accurate => $accurate,
order => $order,
tag => "bareos::server::${bareos::director}"
}
}