Puppet Class: postgresql::backup
- Defined in:
- modules/postgresql/manifests/backup.pp
Overview
class { '::postgresql::backup': } backup::set { 'postgresql': }
Or add your custom Bacula fileset in modules/profile/manifests/backup/director.pp)
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 |
# File 'modules/postgresql/manifests/backup.pp', line 20
class postgresql::backup(
String $dump_interval = '*-*-* 01:23:00',
Stdlib::Unixpath $path = '/srv/postgres-backup',
Integer $rotate_days = 7,
Boolean $do_backups = true,
) {
file { $path:
ensure => 'directory',
owner => 'postgres',
group => 'postgres',
mode => '0750',
}
# Keep the file in case manual dump need to be done even if $do_backups is False
file { '/usr/local/bin/pg-dump-all':
ensure => 'file',
owner => 'root',
group => 'root',
mode => '0555',
source => 'puppet:///modules/postgresql/dump-all.sh',
}
$active_ensure = $do_backups.bool2str('present', 'absent')
systemd::timer::job { 'postgres-dump':
ensure => $active_ensure,
description => 'Regular jobs to dump all databases and meta information',
user => 'postgres',
command => "/usr/local/bin/pg-dump-all ${path}",
interval => {
'start' => 'OnCalendar',
'interval' => $dump_interval,
},
}
$clean_hour = fqdn_rand(23, 'pgclean')
$clean_minute = fqdn_rand(59, 'pgclean')
systemd::timer::job { 'rotate-postgres-dump':
ensure => $active_ensure,
description => 'Regular jobs to clean up old dumps',
user => 'postgres',
command => "/usr/bin/find ${path} -type f -name '*.sql.gz' -mtime +${rotate_days} -delete",
interval => {
'start' => 'OnCalendar',
'interval' => "*-*-* ${clean_hour}:${clean_minute}:00",
},
}
}
|