File tree 7 files changed +27
-10
lines changed
7 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 13
13
$backupdirgroup = $mysql::params::root_group,
14
14
$backupcompress = true ,
15
15
$backuprotate = 30,
16
+ $backupmethod = ' ' ,
16
17
$ignore_events = true ,
17
18
$delete_before_dump = false ,
18
19
$backupdatabases = [],
Original file line number Diff line number Diff line change 12
12
$backupdirgroup = $mysql::params::root_group,
13
13
$backupcompress = true ,
14
14
$backuprotate = 30,
15
+ $backupmethod = ' mysqldump' ,
15
16
$ignore_events = true ,
16
17
$delete_before_dump = false ,
17
18
$backupdatabases = [],
Original file line number Diff line number Diff line change 1
1
# @summary
2
- # "Provider" for Percona XtraBackup
2
+ # "Provider" for Percona XtraBackup/MariaBackup
3
3
# @api private
4
4
#
5
5
class mysql::backup::xtrabackup (
8
8
$backuppassword = undef ,
9
9
$backupdir = ' ' ,
10
10
$maxallowedpacket = ' 1M' ,
11
- $backupmethod = ' mysqldump ' ,
11
+ $backupmethod = ' xtrabackup ' ,
12
12
$backupdirmode = ' 0700' ,
13
13
$backupdirowner = ' root' ,
14
14
$backupdirgroup = $mysql::params::root_group,
26
26
$postscript = false ,
27
27
$execpath = ' /usr/bin:/usr/sbin:/bin:/sbin' ,
28
28
$optional_args = [],
29
- $additional_cron_args = ' '
29
+ $additional_cron_args = ' --backup '
30
30
) inherits mysql::params {
31
31
32
32
ensure_packages($xtrabackup_package_name )
49
49
50
50
cron { 'xtrabackup-weekly' :
51
51
ensure => $ensure ,
52
- command => " /usr/local/sbin/xtrabackup.sh ${backupdir} ${additional_cron_args} " ,
52
+ command => " /usr/local/sbin/xtrabackup.sh --target-dir= ${backupdir} ${additional_cron_args} " ,
53
53
user => ' root' ,
54
54
hour => $time [0],
55
55
minute => $time [1],
59
59
60
60
cron { 'xtrabackup-daily' :
61
61
ensure => $ensure ,
62
- command => " /usr/local/sbin/xtrabackup.sh --incremental ${backupdir} ${additional_cron_args} " ,
62
+ command => " /usr/local/sbin/xtrabackup.sh --incremental-basedir= ${backupdir} --target-dir= ${backupdir} /`date +%F_%H-%M-%S` ${additional_cron_args} " ,
63
63
user => ' root' ,
64
64
hour => $time [0],
65
65
minute => $time [1],
Original file line number Diff line number Diff line change 64
64
$backupdirgroup = ' root' ,
65
65
$backupcompress = true ,
66
66
$backuprotate = 30,
67
+ $backupmethod = undef ,
67
68
$ignore_events = true ,
68
69
$delete_before_dump = false ,
69
70
$backupdatabases = [],
95
96
' backupdirgroup' => $backupdirgroup ,
96
97
' backupcompress' => $backupcompress ,
97
98
' backuprotate' => $backuprotate ,
99
+ ' backupmethod' => $backupmethod ,
98
100
' ignore_events' => $ignore_events ,
99
101
' delete_before_dump' => $delete_before_dump ,
100
102
' backupdatabases' => $backupdatabases ,
Original file line number Diff line number Diff line change @@ -363,7 +363,7 @@ class { 'mysql::server': }
363
363
364
364
it 'contains the wrapper script' do
365
365
is_expected . to contain_file ( 'xtrabackup.sh' ) . with_content (
366
- %r{^innobackupex \s +.*?" \$ @" } ,
366
+ %r{( \n *^xtrabackup \s +.*\$ @) } ,
367
367
)
368
368
end
369
369
@@ -398,6 +398,19 @@ class { 'mysql::server': }
398
398
)
399
399
end
400
400
end
401
+ context 'with mariabackup' do
402
+ let ( :params ) do
403
+ default_params . merge ( provider : 'xtrabackup' ,
404
+ backupmethod : 'mariabackup'
405
+ )
406
+ end
407
+
408
+ it 'contain the mariabackup executor' do
409
+ is_expected . to contain_file ( 'xtrabackup.sh' ) . with_content (
410
+ %r{(\n *^mariabackup\s +.*\$ @)} ,
411
+ )
412
+ end
413
+ end
401
414
end
402
415
end
403
416
end
Original file line number Diff line number Diff line change @@ -91,18 +91,18 @@ cleanup
91
91
<% if @file_per_database -%>
92
92
mysql --defaults-extra-file=$TMPFILE -s -r -N -e 'SHOW DATABASES' | while read dbname
93
93
do
94
- mysqldump --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
94
+ <%= @backupmethod -%> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
95
95
${ADDITIONAL_OPTIONS} \
96
96
${dbname} <% if @backupcompress %> | bzcat -zc <% end %> > ${DIR}/${PREFIX}${dbname}_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> .bz2<% end %>
97
97
done
98
98
<% else -%>
99
- mysqldump --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
99
+ <%= @backupmethod -%> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
100
100
${ADDITIONAL_OPTIONS} \
101
101
--all-databases <% if @backupcompress %> | bzcat -zc <% end %> > ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> .bz2<% end %>
102
102
<% end -%>
103
103
<% else -%>
104
104
<% @backupdatabases . each do |db | -%>
105
- mysqldump --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
105
+ <%= @backupmethod -%> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
106
106
${ADDITIONAL_OPTIONS} \
107
107
<%= db %> <% if @backupcompress %> | bzcat -zc <% end %> > ${DIR}/${PREFIX}<%= db %> _`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> .bz2<% end %>
108
108
<% end -%>
Original file line number Diff line number Diff line change 28
28
<%- end -%>
29
29
<%- end -%>
30
30
31
- innobackupex <%= _innobackupex_args %> "$@"
31
+ <%= @backupmethod -%> <%= _innobackupex_args %> $@
32
32
33
33
<% if @postscript -%>
34
34
<%- [@postscript].flatten.compact.each do |script| %>
You can’t perform that action at this time.
0 commit comments