Puppet Class: profile::mariadb::backup::transfer

Defined in:
modules/profile/manifests/mariadb/backup/transfer.pp

Overview

Create remote xtrabackup/mariabackup backups By using transfer.py



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
# File 'modules/profile/manifests/mariadb/backup/transfer.pp', line 3

class profile::mariadb::backup::transfer {
    include ::passwords::mysql::dump

    require_package(
        'transferpy',
        'python3-yaml',
    )

    # mysql dir must be handled by a separate profile, not done here
    # as it depends on the available owner (root, mysql, dump)
    # file { '/etc/mysql':
    # }

    $stats_user = $passwords::mysql::dump::stats_user
    $stats_password = $passwords::mysql::dump::stats_pass
    # Configuration file where the daily backup routine (source hosts,
    # destination, statistics db is configured
    # Can contain private data like db passwords
    file { '/etc/mysql/backups.cnf':
        ensure    => present,
        owner     => 'root',
        group     => 'root',
        mode      => '0400',
        show_diff => false,
        content   => template("profile/mariadb/backup_config/${::hostname}.cnf.erb"),
        require   => [File['/etc/mysql'],
        ],
    }

    # Small utility that reads the backup configuration and produces
    # snapshots of all configured hosts
    file { '/usr/local/bin/remote_backup_mariadb.py':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        source  => 'puppet:///modules/profile/mariadb/remote_backup_mariadb.py',
        require => [Package['transferpy'],
                    Package['python3-yaml'],
                    File['/etc/mysql/backups.cnf'],
        ],
    }

    cron { 'regular_snapshot':
        minute  => 0,
        hour    => 19,
        weekday => [0, 2, 3, 5],
        user    => 'root',
        command => "/usr/bin/python3 \
/usr/local/bin/remote_backup_mariadb.py > /dev/null 2>&1",
        require => [File['/usr/local/bin/remote_backup_mariadb.py'],
        ],
    }
}