28
|
1 |
# See README.me for usage. |
|
2 |
class mysql::backup::xtrabackup ( |
|
3 |
$backupuser = '', |
|
4 |
$backuppassword = '', |
|
5 |
$backupdir = '', |
|
6 |
$backupmethod = 'mysqldump', |
|
7 |
$backupdirmode = '0700', |
|
8 |
$backupdirowner = 'root', |
|
9 |
$backupdirgroup = $mysql::params::root_group, |
|
10 |
$backupcompress = true, |
|
11 |
$backuprotate = 30, |
|
12 |
$ignore_events = true, |
|
13 |
$delete_before_dump = false, |
|
14 |
$backupdatabases = [], |
|
15 |
$file_per_database = false, |
|
16 |
$include_triggers = true, |
|
17 |
$include_routines = false, |
|
18 |
$ensure = 'present', |
|
19 |
$time = ['23', '5'], |
|
20 |
$prescript = false, |
|
21 |
$postscript = false, |
|
22 |
$execpath = '/usr/bin:/usr/sbin:/bin:/sbin', |
|
23 |
) { |
|
24 |
|
|
25 |
package{ 'percona-xtrabackup': |
|
26 |
ensure => $ensure, |
|
27 |
} |
|
28 |
|
|
29 |
cron { 'xtrabackup-weekly': |
|
30 |
ensure => $ensure, |
|
31 |
command => "/usr/local/sbin/xtrabackup.sh ${backupdir}", |
|
32 |
user => 'root', |
|
33 |
hour => $time[0], |
|
34 |
minute => $time[1], |
|
35 |
weekday => 0, |
|
36 |
require => Package['percona-xtrabackup'], |
|
37 |
} |
|
38 |
|
|
39 |
cron { 'xtrabackup-daily': |
|
40 |
ensure => $ensure, |
|
41 |
command => "/usr/local/sbin/xtrabackup.sh --incremental ${backupdir}", |
|
42 |
user => 'root', |
|
43 |
hour => $time[0], |
|
44 |
minute => $time[1], |
|
45 |
weekday => 1-6, |
|
46 |
require => Package['percona-xtrabackup'], |
|
47 |
} |
|
48 |
|
|
49 |
file { 'mysqlbackupdir': |
|
50 |
ensure => 'directory', |
|
51 |
path => $backupdir, |
|
52 |
mode => $backupdirmode, |
|
53 |
owner => $backupdirowner, |
|
54 |
group => $backupdirgroup, |
|
55 |
} |
|
56 |
|
|
57 |
file { 'xtrabackup.sh': |
|
58 |
ensure => $ensure, |
|
59 |
path => '/usr/local/sbin/xtrabackup.sh', |
|
60 |
mode => '0700', |
|
61 |
owner => 'root', |
|
62 |
group => $mysql::params::root_group, |
|
63 |
content => template('mysql/xtrabackup.sh.erb'), |
|
64 |
} |
|
65 |
} |