Skip to content

Commit 098b71e

Browse files
committed
Use create_resources('class'...
1 parent 6ad2fd7 commit 098b71e

File tree

6 files changed

+69
-5
lines changed

6 files changed

+69
-5
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,34 @@ An array of two elements to set the backup time. Allows ['23', '5'] or ['3', '4
353353

354354
A script that is executed at when the backup is finished. This could be used to (r)sync the backup to a central store. This script can be either a single line that is directly executed or a number of lines, when supplied as an array. It could also be one or more externally managed (executable) files.
355355

356+
#####`provider`
357+
358+
Set backup implementation
359+
360+
* `mysqldump`
361+
* `mysqlbackup`: MySQL Enterprise Backup
362+
* `xtrabackup`: Percona XtraBackup
363+
364+
####mysql::backup::mysqldump
365+
366+
Implements mysql::server::backup with mysqldump
367+
368+
Backup type: Logical
369+
370+
####mysql::backup::mysqlbackup
371+
372+
Implements mysql::server::backup with MySQL Enterprise Backup from Oracle
373+
374+
Backup type: Physical
375+
376+
For this you need the meb package, which is available in RPM and TAR format from Oracle. For Ubuntu you can use [meb-deb](https://github.com/dveeden/meb-deb) to create a package from an official tarball.
377+
378+
####mysql::backup::xtrabackup
379+
380+
Implements mysql::server::backup with XtraBackup from Percona
381+
382+
Backup type: Physical
383+
356384
####mysql::server::monitor
357385

358386
#####`mysql_monitor_username`

manifests/backup/mysqlbackup.pp

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# See README.me for usage.
2-
define mysql::backup::mysqlbackup (
2+
class mysql::backup::mysqlbackup (
33
$backupuser,
44
$backuppassword,
55
$backupdir,
@@ -74,6 +74,24 @@
7474
require => Package['meb'],
7575
}
7676

77+
$default_options = {
78+
'mysqlbackup' => {
79+
'backup-dir' => $backupdir,
80+
'with-timestamp' => true,
81+
'incremental_base' => 'history:last_backup',
82+
'incremental_backup_dir' => $backupdir,
83+
'user' => $backupuser,
84+
'password' => $backuppassword,
85+
}
86+
}
87+
$options = mysql_deepmerge($default_options, $override_options)
88+
89+
file { 'mysqlbackup-config-file':
90+
path => '/etc/mysql/conf.d/meb.cnf',
91+
content => template('mysql/meb.cnf.erb'),
92+
mode => '0600',
93+
}
94+
7795
file { 'mysqlbackupdir':
7896
ensure => 'directory',
7997
path => $backupdir,

manifests/backup/mysqldump.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# See README.me for usage.
2-
define mysql::backup::mysqldump (
2+
class mysql::backup::mysqldump (
33
$backupuser,
44
$backuppassword,
55
$backupdir,

manifests/backup/xtrabackup.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# See README.me for usage.
2-
define mysql::backup::xtrabackup (
2+
class mysql::backup::xtrabackup (
33
$backupuser,
44
$backuppassword,
55
$backupdir,

manifests/server/backup.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
$provider = 'mysqldump',
2020
) {
2121

22-
create_resources("mysql::backup::${provider}", {
23-
"ensure backup is ${ensure} with ${provider}" => {
22+
create_resources("class", {
23+
"mysql::backup::${provider}" => {
2424
'backupuser' => $backupuser,
2525
'backuppassword' => $backuppassword,
2626
'backupdir' => $backupdir,

templates/meb.cnf.erb

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### MANAGED BY PUPPET ###
2+
3+
<% @options.sort.map do |k,v| -%>
4+
<% if v.is_a?(Hash) -%>
5+
[<%= k %>]
6+
<% v.sort.map do |ki, vi| -%>
7+
<% if vi == true or v == '' -%>
8+
<%= ki %>
9+
<% elsif vi.is_a?(Array) -%>
10+
<% vi.each do |vii| -%>
11+
<%= ki %> = <%= vii %>
12+
<% end -%>
13+
<% elsif ![nil, '', :undef].include?(vi) -%>
14+
<%= ki %> = <%= vi %>
15+
<% end -%>
16+
<% end -%>
17+
<% end %>
18+
<% end -%>

0 commit comments

Comments
 (0)