Skip to content

Commit 6ab0d29

Browse files
authored
Merge pull request #1522 from JvGinkel/fix_undef_touch
xtrabackup.sh only touch when backup_success_file_path is set
2 parents 9a83314 + cf4628b commit 6ab0d29

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

spec/classes/mysql_backup_xtrabackup_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class { 'mysql::server': }
2525
default_params
2626
end
2727

28+
it 'does not contain the touch command' do
29+
is_expected.to contain_file('xtrabackup.sh').without_content(
30+
%r{(^\s+touch\s+$)},
31+
)
32+
end
33+
2834
it 'contains the wrapper script' do
2935
is_expected.to contain_file('xtrabackup.sh').with_content(
3036
%r{(\n*^xtrabackup\s+.*\$@)},
@@ -304,6 +310,18 @@ class { 'mysql::server': }
304310
)
305311
end
306312
end
313+
314+
context 'with backup_success_file_path' do
315+
let(:params) do
316+
{ backup_success_file_path: '/tmp/backup_success' }.merge(default_params)
317+
end
318+
319+
it 'contain the touch /tmp/backup_success command' do
320+
is_expected.to contain_file('xtrabackup.sh').with_content(
321+
%r{(^\s+touch /tmp/backup_success$)},
322+
)
323+
end
324+
end
307325
end
308326
end
309327
# rubocop:enable RSpec/NestedGroups

templates/xtrabackup.sh.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ cleanup
5959
<% unless @delete_before_dump -%>
6060
if [ $? -eq 0 ] ; then
6161
cleanup
62+
<% if @backup_success_file_path -%>
6263
touch <%= @backup_success_file_path %>
64+
<% end -%>
6365
fi
6466
<% end -%>
6567

0 commit comments

Comments
 (0)