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
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'manifests/backup/mariabackup.pp', line 10
class mariadb::backup::mariabackup (
$mariabackup_package_name = $mariadb::params::backup_package_name,
$backupuser = undef,
$backuppassword = undef,
$backupdir = $mariadb::params::backupdir,
$backupmethod = 'mariabackup',
$backupdirmode = '0700',
$backupdirowner = 'root',
$backupdirgroup = 'root',
$backupcompress = true,
$backupdatabases = [],
$ensure = 'present',
$time = ['23', '5'],
$prescript = false,
$postscript = false,
$execpath = '/usr/bin:/usr/sbin:/bin:/sbin',
$optional_args = [],
$additional_cron_args = '', # lint:ignore:empty_string_assignment
$incremental = true,
$logging_enabled = false,
$log_path = $mariadb::params::home,
$log_file = 'mariabackup.log'
) inherits mariadb::params {
ensure_packages($mariabackup_package_name)
$_redirect = $logging_enabled ? {
true => ">>${log_path}/${log_file} 2>&1",
default => undef,
}
if $backupuser and $backuppassword {
mysql_user { "${backupuser}@localhost":
ensure => $ensure,
password_hash => mysql::password($backuppassword),
require => Class['mysql::server::root_password'],
}
mysql_grant { "${backupuser}@localhost/*.*":
ensure => $ensure,
user => "${backupuser}@localhost",
table => '*.*',
privileges => [ 'RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT' ],
require => Mysql_user["${backupuser}@localhost"],
}
}
cron { 'mariabackup':
ensure => $ensure,
command => "/usr/local/sbin/mariabackup.sh ${additional_cron_args}${_redirect}",
user => 'root',
hour => $time[0],
minute => $time[1],
weekday => '0-6',
require => Package[$mariabackup_package_name],
}
file { 'mysqlbackupdir':
ensure => 'directory',
path => $backupdir,
mode => $backupdirmode,
owner => $backupdirowner,
group => $backupdirgroup,
}
file { 'mariabackup.sh':
ensure => $ensure,
path => '/usr/local/sbin/mariabackup.sh',
mode => '0700',
owner => 'root',
group => 'root',
content => template('mariadb/backup/mariabackup.sh.erb'),
}
}
|