forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #649 from dveeden/newbackupprovider
Use backup providers
- Loading branch information
Showing
6 changed files
with
306 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# See README.me for usage. | ||
class mysql::backup::mysqlbackup ( | ||
$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), | ||
provider => 'mysql', | ||
require => Class['mysql::server::root_password'], | ||
} | ||
|
||
package { 'meb': | ||
ensure => $ensure, | ||
} | ||
|
||
# http://dev.mysql.com/doc/mysql-enterprise-backup/3.11/en/mysqlbackup.privileges.html | ||
mysql_grant { "${backupuser}@localhost/*.*": | ||
ensure => $ensure, | ||
user => "${backupuser}@localhost", | ||
table => '*.*', | ||
privileges => [ 'RELOAD', 'SUPER', 'REPLICATION CLIENT' ], | ||
require => Mysql_user["${backupuser}@localhost"], | ||
} | ||
|
||
mysql_grant { "${backupuser}@localhost/mysql.backup_progress": | ||
ensure => $ensure, | ||
user => "${backupuser}@localhost", | ||
table => 'mysql.backup_progress', | ||
privileges => [ 'CREATE', 'INSERT', 'DROP', 'UPDATE' ], | ||
require => Mysql_user["${backupuser}@localhost"], | ||
} | ||
|
||
mysql_grant { "${backupuser}@localhost/mysql.backup_history": | ||
ensure => $ensure, | ||
user => "${backupuser}@localhost", | ||
table => 'mysql.backup_history', | ||
privileges => [ 'CREATE', 'INSERT', 'SELECT', 'DROP', 'UPDATE' ], | ||
require => Mysql_user["${backupuser}@localhost"], | ||
} | ||
|
||
cron { 'mysqlbackup-weekly': | ||
ensure => $ensure, | ||
command => 'mysqlbackup backup', | ||
user => 'root', | ||
hour => $time[0], | ||
minute => $time[1], | ||
weekday => 0, | ||
require => Package['meb'], | ||
} | ||
|
||
cron { 'mysqlbackup-daily': | ||
ensure => $ensure, | ||
command => 'mysqlbackup --incremental backup', | ||
user => 'root', | ||
hour => $time[0], | ||
minute => $time[1], | ||
weekday => 1-6, | ||
require => Package['meb'], | ||
} | ||
|
||
$default_options = { | ||
'mysqlbackup' => { | ||
'backup-dir' => $backupdir, | ||
'with-timestamp' => true, | ||
'incremental_base' => 'history:last_backup', | ||
'incremental_backup_dir' => $backupdir, | ||
'user' => $backupuser, | ||
'password' => $backuppassword, | ||
} | ||
} | ||
$options = mysql_deepmerge($default_options, $override_options) | ||
|
||
file { 'mysqlbackup-config-file': | ||
path => '/etc/mysql/conf.d/meb.cnf', | ||
content => template('mysql/meb.cnf.erb'), | ||
mode => '0600', | ||
} | ||
|
||
file { 'mysqlbackupdir': | ||
ensure => 'directory', | ||
path => $backupdir, | ||
mode => $backupdirmode, | ||
owner => $backupdirowner, | ||
group => $backupdirgroup, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# See README.me for usage. | ||
class mysql::backup::mysqldump ( | ||
$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), | ||
provider => 'mysql', | ||
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, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# See README.me for usage. | ||
class mysql::backup::xtrabackup ( | ||
$backupuser, | ||
$backuppassword, | ||
$backupdir, | ||
$backupmethod = 'mysqldump', | ||
$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), | ||
provider => 'mysql', | ||
require => Class['mysql::server::root_password'], | ||
} | ||
|
||
package{ 'percona-xtrabackup': | ||
ensure => $ensure, | ||
} | ||
cron { 'xtrabackup-weekly': | ||
ensure => $ensure, | ||
command => 'innobackupex $backupdir', | ||
user => 'root', | ||
hour => $time[0], | ||
minute => $time[1], | ||
weekday => 0, | ||
require => Package['percona-xtrabackup'], | ||
} | ||
cron { 'xtrabackup-daily': | ||
ensure => $ensure, | ||
command => 'innobackupex --incremental $backupdir', | ||
user => 'root', | ||
hour => $time[0], | ||
minute => $time[1], | ||
weekday => 1-6, | ||
require => Package['percona-xtrabackup'], | ||
} | ||
|
||
file { 'mysqlbackupdir': | ||
ensure => 'directory', | ||
path => $backupdir, | ||
mode => $backupdirmode, | ||
owner => $backupdirowner, | ||
group => $backupdirgroup, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,43 @@ | ||
# See README.me for usage. | ||
class mysql::server::backup ( | ||
$backupuser, | ||
$backuppassword, | ||
$backupdir, | ||
$backupdirmode = '0700', | ||
$backupdirowner = 'root', | ||
$backupdirgroup = 'root', | ||
$backupcompress = true, | ||
$backuprotate = 30, | ||
$ignore_events = true, | ||
$backupuser = undef, | ||
$backuppassword = undef, | ||
$backupdir = undef, | ||
$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', | ||
$backupdatabases = [], | ||
$file_per_database = false, | ||
$ensure = 'present', | ||
$time = ['23', '5'], | ||
$postscript = false, | ||
$execpath = '/usr/bin:/usr/sbin:/bin:/sbin', | ||
$provider = 'mysqldump', | ||
) { | ||
|
||
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, | ||
} | ||
create_resources("class", { | ||
"mysql::backup::${provider}" => { | ||
'backupuser' => $backupuser, | ||
'backuppassword' => $backuppassword, | ||
'backupdir' => $backupdir, | ||
'backupdirmode' => $backupdirmode, | ||
'backupdirowner' => $backupdirowner, | ||
'backupdirgroup' => $backupdirgroup, | ||
'backupcompress' => $backupcompress, | ||
'backuprotate' => $backuprotate, | ||
'ignore_events' => $ignore_events, | ||
'delete_before_dump' => $delete_before_dump, | ||
'backupdatabases' => $backupdatabases, | ||
'file_per_database' => $file_per_database, | ||
'ensure' => $ensure, | ||
'time' => $time, | ||
'postscript' => $postscript, | ||
'execpath' => $execpath, | ||
} | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
### MANAGED BY PUPPET ### | ||
|
||
<% @options.sort.map do |k,v| -%> | ||
<% if v.is_a?(Hash) -%> | ||
[<%= k %>] | ||
<% v.sort.map do |ki, vi| -%> | ||
<% if vi == true or v == '' -%> | ||
<%= ki %> | ||
<% elsif vi.is_a?(Array) -%> | ||
<% vi.each do |vii| -%> | ||
<%= ki %> = <%= vii %> | ||
<% end -%> | ||
<% elsif ![nil, '', :undef].include?(vi) -%> | ||
<%= ki %> = <%= vi %> | ||
<% end -%> | ||
<% end -%> | ||
<% end %> | ||
<% end -%> |