summaryrefslogtreecommitdiff
path: root/manifests/server/cron/backup.pp
blob: 671ad9ca43fcf60dc0cd05b5fcc26e406ec9d035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# setup a basic cronjob to backup mysql database
class mysql::server::cron::backup {
  if $mysql::server::manage_backup_dir {
    file { 'mysql_backup_dir':
      ensure  => directory,
      path    => $mysql::server::backup_dir,
      before  => Cron['mysql_backup_cron'],
      owner   => root,
      group   => 0,
      mode    => '0700';
    }
  }

  cron { 'mysql_backup_cron':
    command => "/usr/bin/mysqldump --default-character-set=utf8 --all-databases --create-options --flush-logs --lock-tables --single-transaction | gzip > ${mysql::server::backup_dir}/mysqldump.sql.gz && chmod 600 ${mysql::server::backup_dir}/mysqldump.sql.gz",
    user    => 'root',
    minute  => 0,
    hour    => 1,
    require => [ Exec['mysql_set_rootpw'], File['mysql_root_cnf'] ],
  }
}