File tree 6 files changed +38
-4
lines changed
6 files changed +38
-4
lines changed Original file line number Diff line number Diff line change 29
29
$optional_args = [],
30
30
$incremental_backups = false ,
31
31
$install_cron = true ,
32
+ $compression_command = undef ,
33
+ $compression_extension = undef ,
32
34
) inherits mysql::params {
33
35
mysql_user { "${backupuser}@localhost" :
34
36
ensure => $ensure ,
Original file line number Diff line number Diff line change 30
30
$mysqlbackupdir_target = undef ,
31
31
$incremental_backups = false ,
32
32
$install_cron = true ,
33
+ $compression_command = ' bzcat -zc' ,
34
+ $compression_extension = ' .bz2'
33
35
) inherits mysql::params {
34
36
unless $::osfamily == ' FreeBSD' {
35
- if $backupcompress {
37
+ if $backupcompress and $compression_command == ' bzcat -zc ' {
36
38
ensure_packages([' bzip2' ])
37
39
Package[' bzip2' ] -> File [' mysqlbackup.sh' ]
38
40
}
Original file line number Diff line number Diff line change 31
31
$additional_cron_args = ' --backup' ,
32
32
$incremental_backups = true ,
33
33
$install_cron = true ,
34
+ $compression_command = undef ,
35
+ $compression_extension = undef ,
34
36
) inherits mysql::params {
35
37
ensure_packages($xtrabackup_package_name )
36
38
Original file line number Diff line number Diff line change 67
67
# Specifies an array of optional arguments which should be passed through to the backup tool. (Supported by the xtrabackup and mysqldump providers.)
68
68
# @param install_cron
69
69
# Manage installation of cron package
70
+ # @param compression_command
71
+ # Configure the command used to compress the backup (when using the mysqldump provider). Make sure the command exists
72
+ # on the target system. Packages for it are NOT automatically installed.
73
+ # @param compression_extension
74
+ # Configure the file extension for the compressed backup (when using the mysqldump provider)
70
75
class mysql::server::backup (
71
76
$backupuser = undef ,
72
77
$backuppassword = undef ,
94
99
$optional_args = [],
95
100
$incremental_backups = true ,
96
101
$install_cron = true ,
102
+ $compression_command = undef ,
103
+ $compression_extension = undef
97
104
) inherits mysql::params {
98
105
if $prescript and $provider =~ /(mysqldump|mysqlbackup)/ {
99
106
warning (translate(" The 'prescript' option is not currently implemented for the %{provider} backup provider." ,
127
134
' optional_args' => $optional_args ,
128
135
' incremental_backups' => $incremental_backups ,
129
136
' install_cron' => $install_cron ,
137
+ ' compression_command' => $compression_command ,
138
+ ' compression_extension' => $compression_extension ,
130
139
}
131
140
})
132
141
}
Original file line number Diff line number Diff line change @@ -52,6 +52,25 @@ class { 'mysql::server': }
52
52
)
53
53
}
54
54
end
55
+
56
+ context 'with compression_command' do
57
+ let ( :params ) do
58
+ {
59
+ compression_command : 'TEST -TEST' ,
60
+ compression_extension : '.TEST'
61
+ } . merge ( default_params )
62
+ end
63
+
64
+ it {
65
+ is_expected . to contain_file ( 'mysqlbackup.sh' ) . with_content (
66
+ %r{(\| TEST -TEST)} ,
67
+ )
68
+ is_expected . to contain_file ( 'mysqlbackup.sh' ) . with_content (
69
+ %r{(\. TEST)} ,
70
+ )
71
+ is_expected . not_to contain_package ( 'bzip2' )
72
+ }
73
+ end
55
74
end
56
75
end
57
76
# rubocop:enable RSpec/NestedGroups
Original file line number Diff line number Diff line change @@ -93,18 +93,18 @@ mysql --defaults-extra-file=$TMPFILE -s -r -N -e 'SHOW DATABASES' | while read d
93
93
do
94
94
<%= @backupmethod -%> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
95
95
${ADDITIONAL_OPTIONS} \
96
- ${dbname} <% if @backupcompress %> | bzcat -zc <% end %> > ${DIR}/${PREFIX}${dbname}_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> .bz2 <% end %>
96
+ ${dbname} <% if @backupcompress %> | <%= @compression_command %> <% end %> > ${DIR}/${PREFIX}${dbname}_`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> <%= @compression_extension %> <% end %>
97
97
done
98
98
<% else -%>
99
99
<%= @backupmethod -%> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
100
100
${ADDITIONAL_OPTIONS} \
101
- --all-databases <% if @backupcompress %> | bzcat -zc <% end %> > ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> .bz2 <% end %>
101
+ --all-databases <% if @backupcompress %> | <%= @compression_command %> <% end %> > ${DIR}/${PREFIX}`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> <%= @compression_extension %> <% end %>
102
102
<% end -%>
103
103
<% else -%>
104
104
<% @backupdatabases . each do |db | -%>
105
105
<%= @backupmethod -%> --defaults-extra-file=$TMPFILE --opt --flush-logs --single-transaction \
106
106
${ADDITIONAL_OPTIONS} \
107
- <%= db %> <% if @backupcompress %> | bzcat -zc <% end %> > ${DIR}/${PREFIX}<%= db %> _`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> .bz2 <% end %>
107
+ <%= db %> <% if @backupcompress %> | <%= @compression_command %> <% end %> > ${DIR}/${PREFIX}<%= db %> _`date +%Y%m%d-%H%M%S`.sql<% if @backupcompress %> <%= @compression_extension %> <% end %>
108
108
<% end -%>
109
109
<% end -%>
110
110
You can’t perform that action at this time.
0 commit comments