Puppet Class: mysql::server::backup

Defined in:
manifests/server/backup.pp

Overview

See README.me for usage.

Parameters:

  • backupuser (Any)
  • backuppassword (Any)
  • backupdir (Any)
  • backupdirmode (Any) (defaults to: '0700')
  • backupdirowner (Any) (defaults to: 'root')
  • backupdirgroup (Any) (defaults to: 'root')
  • backupcompress (Any) (defaults to: true)
  • backuprotate (Any) (defaults to: 30)
  • ignore_events (Any) (defaults to: true)
  • delete_before_dump (Any) (defaults to: false)
  • backupdatabases (Any) (defaults to: [])
  • file_per_database (Any) (defaults to: false)
  • ensure (Any) (defaults to: 'present')
  • time (Any) (defaults to: ['23', '5'])
  • postscript (Any) (defaults to: false)
  • execpath (Any) (defaults to: '/usr/bin:/usr/sbin:/bin:/sbin')


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'manifests/server/backup.pp', line 2

class mysql::server::backup (
  $backupuser,
  $backuppassword,
  $backupdir,
  $backupdirmode = '0700',
  $backupdirowner = 'root',
  $backupdirgroup = 'root',
  $backupcompress = true,
  $backuprotate = 30,
  $ignore_events = true,
  $delete_before_dump = false,
  $backupdatabases = [],
  $file_per_database = false,
  $ensure = 'present',
  $time = ['23', '5'],
  $postscript = false,
  $execpath   = '/usr/bin:/usr/sbin:/bin:/sbin',
) {

  mysql_user { "${backupuser}@localhost":
    ensure        => $ensure,
    password_hash => mysql_password($backuppassword),
    require       => Class['mysql::server::root_password'],
  }

  mysql_grant { "${backupuser}@localhost/*.*":
    ensure     => $ensure,
    user       => "${backupuser}@localhost",
    table      => '*.*',
    privileges => [ 'SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS' ],
    require    => Mysql_user["${backupuser}@localhost"],
  }

  cron { 'mysql-backup':
    ensure  => $ensure,
    command => '/usr/local/sbin/mysqlbackup.sh',
    user    => 'root',
    hour    => $time[0],
    minute  => $time[1],
    require => File['mysqlbackup.sh'],
  }

  file { 'mysqlbackup.sh':
    ensure  => $ensure,
    path    => '/usr/local/sbin/mysqlbackup.sh',
    mode    => '0700',
    owner   => 'root',
    group   => 'root',
    content => template('mysql/mysqlbackup.sh.erb'),
  }

  file { 'mysqlbackupdir':
    ensure => 'directory',
    path   => $backupdir,
    mode   => $backupdirmode,
    owner  => $backupdirowner,
    group  => $backupdirgroup,
  }

}