|
1 | 1 | # See README.me for usage.
|
2 | 2 | class mysql::server::backup (
|
3 |
| - $backupuser, |
4 |
| - $backuppassword, |
5 |
| - $backupdir, |
6 |
| - $backupdirmode = '0700', |
7 |
| - $backupdirowner = 'root', |
8 |
| - $backupdirgroup = 'root', |
9 |
| - $backupcompress = true, |
10 |
| - $backuprotate = 30, |
11 |
| - $ignore_events = true, |
| 3 | + $backupuser = undef, |
| 4 | + $backuppassword = undef, |
| 5 | + $backupdir = undef, |
| 6 | + $backupdirmode = '0700', |
| 7 | + $backupdirowner = 'root', |
| 8 | + $backupdirgroup = 'root', |
| 9 | + $backupcompress = true, |
| 10 | + $backuprotate = 30, |
| 11 | + $ignore_events = true, |
12 | 12 | $delete_before_dump = false,
|
13 |
| - $backupdatabases = [], |
14 |
| - $file_per_database = false, |
15 |
| - $ensure = 'present', |
16 |
| - $time = ['23', '5'], |
17 |
| - $postscript = false, |
18 |
| - $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', |
| 13 | + $backupdatabases = [], |
| 14 | + $file_per_database = false, |
| 15 | + $ensure = 'present', |
| 16 | + $time = ['23', '5'], |
| 17 | + $postscript = false, |
| 18 | + $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', |
| 19 | + $provider = 'mysqldump', |
19 | 20 | ) {
|
20 | 21 |
|
21 |
| - mysql_user { "${backupuser}@localhost": |
22 |
| - ensure => $ensure, |
23 |
| - password_hash => mysql_password($backuppassword), |
24 |
| - require => Class['mysql::server::root_password'], |
25 |
| - } |
26 |
| - |
27 |
| - mysql_grant { "${backupuser}@localhost/*.*": |
28 |
| - ensure => $ensure, |
29 |
| - user => "${backupuser}@localhost", |
30 |
| - table => '*.*', |
31 |
| - privileges => [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS' ], |
32 |
| - require => Mysql_user["${backupuser}@localhost"], |
33 |
| - } |
34 |
| - |
35 |
| - cron { 'mysql-backup': |
36 |
| - ensure => $ensure, |
37 |
| - command => '/usr/local/sbin/mysqlbackup.sh', |
38 |
| - user => 'root', |
39 |
| - hour => $time[0], |
40 |
| - minute => $time[1], |
41 |
| - require => File['mysqlbackup.sh'], |
42 |
| - } |
43 |
| - |
44 |
| - file { 'mysqlbackup.sh': |
45 |
| - ensure => $ensure, |
46 |
| - path => '/usr/local/sbin/mysqlbackup.sh', |
47 |
| - mode => '0700', |
48 |
| - owner => 'root', |
49 |
| - group => 'root', |
50 |
| - content => template('mysql/mysqlbackup.sh.erb'), |
51 |
| - } |
52 |
| - |
53 |
| - file { 'mysqlbackupdir': |
54 |
| - ensure => 'directory', |
55 |
| - path => $backupdir, |
56 |
| - mode => $backupdirmode, |
57 |
| - owner => $backupdirowner, |
58 |
| - group => $backupdirgroup, |
59 |
| - } |
| 22 | + create_resources("class", { |
| 23 | + "mysql::backup::${provider}" => { |
| 24 | + 'backupuser' => $backupuser, |
| 25 | + 'backuppassword' => $backuppassword, |
| 26 | + 'backupdir' => $backupdir, |
| 27 | + 'backupdirmode' => $backupdirmode, |
| 28 | + 'backupdirowner' => $backupdirowner, |
| 29 | + 'backupdirgroup' => $backupdirgroup, |
| 30 | + 'backupcompress' => $backupcompress, |
| 31 | + 'backuprotate' => $backuprotate, |
| 32 | + 'ignore_events' => $ignore_events, |
| 33 | + 'delete_before_dump' => $delete_before_dump, |
| 34 | + 'backupdatabases' => $backupdatabases, |
| 35 | + 'file_per_database' => $file_per_database, |
| 36 | + 'ensure' => $ensure, |
| 37 | + 'time' => $time, |
| 38 | + 'postscript' => $postscript, |
| 39 | + 'execpath' => $execpath, |
| 40 | + } |
| 41 | + }) |
60 | 42 |
|
61 | 43 | }
|
0 commit comments