File tree 6 files changed +89
-2
lines changed
6 files changed +89
-2
lines changed Original file line number Diff line number Diff line change 16
16
$include_routines = false ,
17
17
$ensure = ' present' ,
18
18
$time = [' 23' , ' 5' ],
19
+ $prescript = false ,
19
20
$postscript = false ,
20
21
$execpath = ' /usr/bin:/usr/sbin:/bin:/sbin' ,
21
22
) {
Original file line number Diff line number Diff line change 16
16
$include_routines = false ,
17
17
$ensure = ' present' ,
18
18
$time = [' 23' , ' 5' ],
19
+ $prescript = false ,
19
20
$postscript = false ,
20
21
$execpath = ' /usr/bin:/usr/sbin:/bin:/sbin' ,
21
22
) {
Original file line number Diff line number Diff line change 17
17
$include_routines = false ,
18
18
$ensure = ' present' ,
19
19
$time = [' 23' , ' 5' ],
20
+ $prescript = false ,
20
21
$postscript = false ,
21
22
$execpath = ' /usr/bin:/usr/sbin:/bin:/sbin' ,
22
23
) {
27
28
28
29
cron { 'xtrabackup-weekly' :
29
30
ensure => $ensure ,
30
- command => " innobackupex ${backupdir} " ,
31
+ command => " /usr/local/sbin/xtrabackup.sh ${backupdir} " ,
31
32
user => ' root' ,
32
33
hour => $time [0],
33
34
minute => $time [1],
37
38
38
39
cron { 'xtrabackup-daily' :
39
40
ensure => $ensure ,
40
- command => " innobackupex --incremental ${backupdir} " ,
41
+ command => " /usr/local/sbin/xtrabackup.sh --incremental ${backupdir} " ,
41
42
user => ' root' ,
42
43
hour => $time [0],
43
44
minute => $time [1],
52
53
owner => $backupdirowner ,
53
54
group => $backupdirgroup ,
54
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
+ }
55
65
}
Original file line number Diff line number Diff line change 16
16
$include_triggers = false ,
17
17
$ensure = ' present' ,
18
18
$time = [' 23' , ' 5' ],
19
+ $prescript = false ,
19
20
$postscript = false ,
20
21
$execpath = ' /usr/bin:/usr/sbin:/bin:/sbin' ,
21
22
$provider = ' mysqldump' ,
22
23
) {
23
24
25
+ if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ {
26
+ warn(" The \$ prescript option is not currently implemented for the ${provider} backup provider." )
27
+ }
28
+
24
29
create_resources(' class' , {
25
30
" mysql::backup::${provider} " => {
26
31
' backupuser' => $backupuser ,
39
44
' include_triggers' => $include_triggers ,
40
45
' ensure' => $ensure ,
41
46
' time' => $time ,
47
+ ' prescript' => $prescript ,
42
48
' postscript' => $postscript ,
43
49
' execpath' => $execpath ,
44
50
}
Original file line number Diff line number Diff line change 349
349
)
350
350
end
351
351
end
352
+
353
+ context 'with the xtrabackup provider' do
354
+ let ( :params ) do
355
+ default_params . merge ( { :provider => 'xtrabackup' } )
356
+ end
357
+
358
+ it 'should contain the wrapper script' do
359
+ is_expected . to contain_file ( 'xtrabackup.sh' ) . with_content (
360
+ /^innobackupex\s +"\$ @"/
361
+ )
362
+ end
363
+
364
+ context 'with prescript defined' do
365
+ let ( :params ) do
366
+ default_params . merge ( {
367
+ :provider => 'xtrabackup' ,
368
+ :prescript => [
369
+ 'rsync -a /tmp backup01.local-lan:' ,
370
+ 'rsync -a /tmp backup02.local-lan:' ,
371
+ ]
372
+ } )
373
+ end
374
+
375
+ it 'should contain the prescript' do
376
+ is_expected . to contain_file ( 'xtrabackup.sh' ) . with_content (
377
+ /.*rsync -a \/ tmp backup01.local-lan:\n \n rsync -a \/ tmp backup02.local-lan:.*/
378
+ )
379
+ end
380
+ end
381
+
382
+ context 'with postscript defined' do
383
+ let ( :params ) do
384
+ default_params . merge ( {
385
+ :provider => 'xtrabackup' ,
386
+ :postscript => [
387
+ 'rsync -a /tmp backup01.local-lan:' ,
388
+ 'rsync -a /tmp backup02.local-lan:' ,
389
+ ]
390
+ } )
391
+ end
392
+
393
+ it 'should contain the prostscript' do
394
+ is_expected . to contain_file ( 'xtrabackup.sh' ) . with_content (
395
+ /.*rsync -a \/ tmp backup01.local-lan:\n \n rsync -a \/ tmp backup02.local-lan:.*/
396
+ )
397
+ end
398
+ end
399
+ end
352
400
end
353
401
end
354
402
end
Original file line number Diff line number Diff line change
1
+ <%- if @kernel == 'Linux' -%>
2
+ #!/bin/bash
3
+ <%- else -%>
4
+ #!/bin/sh
5
+ <%- end -%>
6
+ #
7
+ # A wrapper for Xtrabackup
8
+ #
9
+ <% if @prescript -%>
10
+ <%- [@prescript].flatten.compact.each do |script| %>
11
+ <%= script %>
12
+ <%- end -%>
13
+ <% end -%>
14
+
15
+ innobackupex "$@"
16
+
17
+ <% if @postscript -%>
18
+ <%- [@postscript].flatten.compact.each do |script| %>
19
+ <%= script %>
20
+ <%- end -%>
21
+ <% end -%>
You can’t perform that action at this time.
0 commit comments