2009-12-10 20:52:50 +01:00
|
|
|
class mysql::server::cron::backup {
|
|
|
|
|
|
|
|
$real_mysql_backup_dir = $mysql_backup_dir ? {
|
|
|
|
'' => '/var/backups/mysql',
|
|
|
|
default => $mysql_backup_dir,
|
|
|
|
}
|
|
|
|
|
2010-04-02 18:08:27 +02:00
|
|
|
case $mysql_manage_backup_dir {
|
|
|
|
false: { info("We don't manage \$mysql_backup_dir ($mysql_backup_dir)") }
|
|
|
|
default: {
|
|
|
|
file { 'mysql_backup_dir':
|
|
|
|
path => $real_mysql_backup_dir,
|
|
|
|
ensure => directory,
|
2010-04-02 18:12:06 +02:00
|
|
|
before => Cron['mysql_backup_cron'],
|
|
|
|
owner => root, group => 0, mode => 0700;
|
2010-04-02 18:08:27 +02:00
|
|
|
}
|
|
|
|
}
|
2009-12-10 20:52:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cron { 'mysql_backup_cron':
|
2010-04-22 19:58:49 +02:00
|
|
|
command => "/usr/bin/mysqldump --default-character-set=utf8 --all-databases --all --flush-logs --lock-tables --single-transaction | gzip > ${real_mysql_backup_dir}/mysqldump.sql.gz && chmod 600 ${real_mysql_backup_dir}/mysqldump.sql.gz",
|
2009-12-10 20:52:50 +01:00
|
|
|
user => 'root',
|
|
|
|
minute => 0,
|
|
|
|
hour => 1,
|
2010-04-02 18:12:06 +02:00
|
|
|
require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ],
|
2009-12-10 20:52:50 +01:00
|
|
|
}
|
|
|
|
}
|