Skip to content

Commit 8ec3b9d

Browse files
committed
Allow backup::mysqldump::time to accept monthday, month, weekday
This adds the missing time parameters to backup::mysqldump, thereby allowing for backup frequency other than daily. It does not change the other providers, and therefore does not change the documentation of server::backup.
1 parent 6825dd5 commit 8ec3b9d

File tree

2 files changed

+65
-6
lines changed

2 files changed

+65
-6
lines changed

manifests/backup/mysqldump.pp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@
6969
}
7070

7171
cron { 'mysql-backup':
72-
ensure => $ensure,
73-
command => '/usr/local/sbin/mysqlbackup.sh',
74-
user => 'root',
75-
hour => $time[0],
76-
minute => $time[1],
77-
require => File['mysqlbackup.sh'],
72+
ensure => $ensure,
73+
command => '/usr/local/sbin/mysqlbackup.sh',
74+
user => 'root',
75+
hour => $time[0],
76+
minute => $time[1],
77+
monthday => $time[2],
78+
month => $time[3],
79+
weekday => $time[4],
80+
require => File['mysqlbackup.sh'],
7881
}
7982

8083
file { 'mysqlbackup.sh':
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require 'spec_helper'
2+
3+
describe 'mysql::backup::mysqldump' do
4+
on_supported_os.each do |os, facts|
5+
context "on #{os}" do
6+
let(:pre_condition) do
7+
<<-EOF
8+
class { 'mysql::server': }
9+
EOF
10+
end
11+
let(:facts) do
12+
facts.merge(root_home: '/root')
13+
end
14+
15+
let(:default_params) do
16+
{ 'backupuser' => 'testuser',
17+
'backuppassword' => 'testpass',
18+
'backupdir' => '/tmp/mysql-backup',
19+
'backuprotate' => '25',
20+
'delete_before_dump' => true,
21+
'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
22+
'maxallowedpacket' => '1M' }
23+
end
24+
25+
context 'with time included' do
26+
let(:params) do
27+
{ time: [23, 59, 30, 12, 6] }.merge(default_params)
28+
end
29+
30+
it {
31+
is_expected.to contain_cron('mysql-backup').with(
32+
hour: 23,
33+
minute: 59,
34+
monthday: 30,
35+
month: 12,
36+
weekday: 6,
37+
)
38+
}
39+
end
40+
41+
context 'with defaults' do
42+
let(:params) { default_params }
43+
44+
it {
45+
is_expected.to contain_cron('mysql-backup').with(
46+
command: '/usr/local/sbin/mysqlbackup.sh',
47+
ensure: 'present',
48+
hour: 23,
49+
minute: 5,
50+
)
51+
}
52+
end
53+
end
54+
end
55+
# rubocop:enable RSpec/NestedGroups
56+
end

0 commit comments

Comments
 (0)