annotate modules/mysql/manifests/backup/xtrabackup.pp @ 454:d0e7979c7e8c

Update PHP configs for Ubuntu Mostly fixing some INI naming so that it is consistent between packages and what we write (so we don't end up with mixed/duplicate content)
author IBBoard <dev@ibboard.co.uk>
date Sun, 13 Aug 2023 15:26:37 +0100
parents c6c9a2cfcfbd
children adf6fe9bbc17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
1 # @summary
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
2 # "Provider" for Percona XtraBackup/MariaBackup
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
3 # @api private
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
4 #
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 class mysql::backup::xtrabackup (
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
6 Optional[String] $backupuser = undef,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
7 Optional[Variant[String, Sensitive[String]]] $backuppassword = undef,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
8 String $backupdir = '',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
9 String[1] $maxallowedpacket = '1M',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
10 String[1] $backupmethod = 'xtrabackup',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
11 String[1] $backupdirmode = '0700',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
12 String[1] $backupdirowner = 'root',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
13 String[1] $backupdirgroup = $mysql::params::root_group,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
14 Boolean $backupcompress = true,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
15 Variant[Integer, String[1]] $backuprotate = 30,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
16 String[1] $backupscript_template = 'mysql/xtrabackup.sh.erb',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
17 Optional[String[1]] $backup_success_file_path = undef,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
18 Boolean $ignore_events = true,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
19 Boolean $delete_before_dump = false,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
20 Array[String[1]] $backupdatabases = [],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
21 Boolean $file_per_database = false,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
22 Boolean $include_triggers = true,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
23 Boolean $include_routines = false,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
24 Enum['present', 'absent'] $ensure = 'present',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
25 Variant[Array[String[1]], Array[Integer]] $time = ['23', '5'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
26 Variant[Boolean, String[1], Array[String[1]]] $prescript = false,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
27 Variant[Boolean, String[1], Array[String[1]]] $postscript = false,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
28 String[1] $execpath = '/usr/bin:/usr/sbin:/bin:/sbin',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
29 Array[String[1]] $optional_args = [],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
30 String[1] $additional_cron_args = '--backup',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
31 Boolean $incremental_backups = true,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
32 Boolean $install_cron = true,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
33 Optional[String[1]] $compression_command = undef,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
34 Optional[String[1]] $compression_extension = undef,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
35 String[1] $backupmethod_package = $mysql::params::xtrabackup_package_name,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
36 Array[String] $excludedatabases = [],
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
37 ) inherits mysql::params {
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
38 ensure_packages($backupmethod_package)
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
40 $backuppassword_unsensitive = if $backuppassword =~ Sensitive {
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
41 $backuppassword.unwrap
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
42 } else {
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
43 $backuppassword
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
44 }
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
45
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
46 if $backupuser and $backuppassword {
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
47 mysql_user { "${backupuser}@localhost":
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
48 ensure => $ensure,
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
49 password_hash => mysql::password($backuppassword),
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
50 require => Class['mysql::server::root_password'],
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
51 }
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
52 # Percona XtraBackup needs additional grants/privileges to work with MySQL 8
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
53 if versioncmp($facts['mysql_version'], '8') >= 0 and !(/(?i:mariadb)/ in $facts['mysqld_version']) {
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
54 if ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '11') >= 0) or
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
55 ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') >= 0) {
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
56 mysql_grant { "${backupuser}@localhost/*.*":
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
57 ensure => $ensure,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
58 user => "${backupuser}@localhost",
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
59 table => '*.*',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
60 privileges => ['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES', 'BACKUP_ADMIN'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
61 require => Mysql_user["${backupuser}@localhost"],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
62 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
63 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
64 else {
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
65 mysql_grant { "${backupuser}@localhost/*.*":
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
66 ensure => $ensure,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
67 user => "${backupuser}@localhost",
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
68 table => '*.*',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
69 privileges => ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT', 'BACKUP_ADMIN'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
70 require => Mysql_user["${backupuser}@localhost"],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
71 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
72 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
73 mysql_grant { "${backupuser}@localhost/performance_schema.keyring_component_status":
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
74 ensure => $ensure,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
75 user => "${backupuser}@localhost",
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
76 table => 'performance_schema.keyring_component_status',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
77 privileges => ['SELECT'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
78 require => Mysql_user["${backupuser}@localhost"],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
79 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
80 mysql_grant { "${backupuser}@localhost/performance_schema.log_status":
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
81 ensure => $ensure,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
82 user => "${backupuser}@localhost",
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
83 table => 'performance_schema.log_status',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
84 privileges => ['SELECT'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
85 require => Mysql_user["${backupuser}@localhost"],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
86 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
87 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
88 else {
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
89 if $facts['os']['family'] == 'debian' and $facts['os']['release']['major'] == '11' or
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
90 ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '22.04') >= 0) {
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
91 mysql_grant { "${backupuser}@localhost/*.*":
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
92 ensure => $ensure,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
93 user => "${backupuser}@localhost",
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
94 table => '*.*',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
95 privileges => ['BINLOG MONITOR', 'RELOAD', 'PROCESS', 'LOCK TABLES'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
96 require => Mysql_user["${backupuser}@localhost"],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
97 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
98 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
99 else {
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
100 mysql_grant { "${backupuser}@localhost/*.*":
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
101 ensure => $ensure,
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
102 user => "${backupuser}@localhost",
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
103 table => '*.*',
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
104 privileges => ['RELOAD', 'PROCESS', 'LOCK TABLES', 'REPLICATION CLIENT'],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
105 require => Mysql_user["${backupuser}@localhost"],
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
106 }
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
107 }
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
108 }
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 }
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
111 if $install_cron {
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
112 if $facts['os']['family'] == 'RedHat' {
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
113 ensure_packages('cronie')
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
114 } elsif $facts['os']['family'] != 'FreeBSD' {
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
115 ensure_packages('cron')
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
116 }
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
117 }
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
118
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
119 if $incremental_backups {
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
120 # Warn if old backups are removed too soon. Incremental backups will fail
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
121 # if the full backup is no longer available.
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
122 if ($backuprotate.convert_to(Integer) < 7) {
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
123 warning('The value for `backuprotate` is too low, it must be set to at least 7 days when using incremental backups.')
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
124 }
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
125
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
126 # The --target-dir uses a more predictable value for the full backup so
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
127 # that it can easily be calculated and used in incremental backup jobs.
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
128 # Besides that it allows to have multiple full backups.
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
129 cron { 'xtrabackup-weekly':
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
130 ensure => $ensure,
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
131 command => "/usr/local/sbin/xtrabackup.sh --target-dir=${backupdir}/$(date +\\%F)_full ${additional_cron_args}",
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
132 user => 'root',
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
133 hour => $time[0],
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
134 minute => $time[1],
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
135 weekday => '0',
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
136 require => Package[$backupmethod_package],
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
137 }
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 }
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
139
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
140 # Wether to use GNU or BSD date format.
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
141 case $facts['os']['family'] {
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
142 'FreeBSD','OpenBSD': {
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
143 $dateformat = '$(date -v-sun +\\%F)_full'
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
144 }
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
145 default: {
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
146 $dateformat = '$(date -d "last sunday" +\\%F)_full'
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
147 }
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
148 }
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
149
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
150 $daily_cron_data = ($incremental_backups) ? {
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
151 true => {
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
152 'directories' => "--incremental-basedir=${backupdir}/${dateformat} --target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)",
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
153 'weekday' => '1-6',
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
154 },
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
155 false => {
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
156 'directories' => "--target-dir=${backupdir}/$(date +\\%F_\\%H-\\%M-\\%S)",
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
157 'weekday' => '*',
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
158 },
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
159 }
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
160
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
161 cron { 'xtrabackup-daily':
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 ensure => $ensure,
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
163 command => "/usr/local/sbin/xtrabackup.sh ${daily_cron_data['directories']} ${additional_cron_args}",
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 user => 'root',
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 hour => $time[0],
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 minute => $time[1],
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
167 weekday => $daily_cron_data['weekday'],
443
c6c9a2cfcfbd Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 389
diff changeset
168 require => Package[$backupmethod_package],
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 }
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
171 file { $backupdir:
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 ensure => 'directory',
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 mode => $backupdirmode,
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 owner => $backupdirowner,
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 group => $backupdirgroup,
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 }
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177
389
668df4711671 Update MySQL modules
IBBoard <dev@ibboard.co.uk>
parents: 244
diff changeset
178 # TODO: use EPP instead of ERB, as EPP can handle Data of Type Sensitive without further ado
244
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
179 file { 'xtrabackup.sh':
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
180 ensure => $ensure,
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
181 path => '/usr/local/sbin/xtrabackup.sh',
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
182 mode => '0700',
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
183 owner => 'root',
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
184 group => $mysql::params::root_group,
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
185 content => template($backupscript_template),
48d3a1948e4d Update MySQL module
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
186 }
26
58d1818c2ded Update MySQL module (which adds "staging" module)
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 }