Puppet Class: profile::wmcs::paws::trove::backup

Defined in:
modules/profile/manifests/wmcs/paws/trove/backup.pp

Overview

Parameters:

  • dbuser (String) (defaults to: lookup('profile::wmcs::paws::trove::dbuser', {default_value => 'paws'}))
  • dbpass (String) (defaults to: lookup('profile::wmcs::paws::trove::dbpass', {default_value => 'notarealpassword'}))
  • dbhost (Stdlib::Fqdn) (defaults to: lookup('profile::wmcs::paws::trove::dbhost', {default_value => 'q45euqdu26j.svc.trove.eqiad1.wikimedia.cloud'}))
  • backupdir (Stdlib::UnixPath) (defaults to: lookup('profile::wmcs::paws::trove::backupdir', {default_value => '/data/project/dbbackups'}))


1
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
62
# File 'modules/profile/manifests/wmcs/paws/trove/backup.pp', line 1

class profile::wmcs::paws::trove::backup (
    String       $dbuser = lookup('profile::wmcs::paws::trove::dbuser', {default_value => 'paws'}),
    String       $dbpass = lookup('profile::wmcs::paws::trove::dbpass', {default_value => 'notarealpassword'}),
    Stdlib::Fqdn $dbhost = lookup('profile::wmcs::paws::trove::dbhost', {default_value => 'q45euqdu26j.svc.trove.eqiad1.wikimedia.cloud'}),
    Stdlib::UnixPath $backupdir = lookup('profile::wmcs::paws::trove::backupdir', {default_value => '/data/project/dbbackups'}),
){
    ensure_packages(['mariadb-client'])

    file { $backupdir:
        ensure => 'directory',
        owner  => 'root',
        group  => 'root',
        mode   => '0700',
    }

    file { '/usr/local/bin/dbdump.sh':
        ensure  => 'present',
        owner   => 'root',
        group   => 'root',
        mode    => '0554',
        content => template('profile/wmcs/paws/trove/dbdump.sh.erb'),
    }

    file { '/etc/dbdump.cfg':
        ensure  => 'present',
        owner   => 'root',
        group   => 'root',
        mode    => '0440',
        content => template('profile/wmcs/paws/trove/dbdump.cfg.erb'),
    }

    file { '/var/log/paws':
        ensure => 'directory',
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    systemd::timer::job { 'paws-dbdump':
        ensure            => 'present',
        user              => 'root',
        description       => 'create a database backup',
        command           => '/usr/local/bin/dbdump.sh',
        logging_enabled   => true,
        logfile_basedir   => '/var/log/paws/',
        logfile_name      => 'dbdump.log',
        syslog_identifier => 'pawsdumps',
        interval          => {'start' => 'OnCalendar', 'interval' => '*-*-* 0:15:00'},
    }

    systemd::timer::job { 'paws-cleanup-mysqldump':
        ensure            => 'present',
        user              => 'root',
        description       => 'delete old dump files to avoid running out of disk space',
        command           => "/usr/bin/find ${backupdir} -name \"*.sql.gz\" -mtime +7 -exec rm {} \\;",
        logging_enabled   => true,
        logfile_basedir   => '/var/log/paws/',
        logfile_name      => 'cleanup-mysqldump.log',
        syslog_identifier => 'pawsdumps-cleanup',
        interval          => {'start' => 'OnCalendar', 'interval' => '*-*-* 23:23:00'},
    }
}