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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'modules/profile/manifests/mariadb/backup/transfer.pp', line 3

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

    require_package(
        'python3',
        'python3-yaml',
        'python3-pymysql',
        'cumin',
    )

    # 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'],
        ],
    }

    # transfer.py: Base utility that allows remote file transfer between hosts,
    # as well as generating backups from mysql hosts
    file { '/usr/local/bin/transfer.py':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        source  => 'puppet:///modules/profile/mariadb/transfer.py',
        require => [Package['python3'],
                    Package['cumin'],
        ],
    }

    # 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 => [File['/usr/local/bin/transfer.py'],
                    File['/etc/mysql/backups.cnf'],
                    Package['python3'],
                    Package['python3-yaml'],
                    Package['cumin'],
        ],
    }

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