postgresql: Added postgresql::server::backup class for database backups.
This commit is contained in:
parent
183147594a
commit
39a60084c4
2 changed files with 76 additions and 0 deletions
|
@ -102,3 +102,44 @@ class postgresql::server($datadir="/srv/pgsql") {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Install PostgreSQL daily backup job
|
||||
#
|
||||
# === Global variables
|
||||
#
|
||||
# $datadir:
|
||||
# Directory where PostgreSQL backups are stored. Defaults
|
||||
# to /srv/pgsql-backup
|
||||
#
|
||||
# $maxage:
|
||||
# How long to keep MariaDB backups. Defaults to 7 days.
|
||||
#
|
||||
class postgresql::server::backup($datadir="/srv/pgsql-backup", $maxage="7") {
|
||||
|
||||
file { $datadir:
|
||||
ensure => directory,
|
||||
mode => "0700",
|
||||
owner => "postgres",
|
||||
group => "postgres",
|
||||
}
|
||||
|
||||
file { "/usr/local/sbin/pgsql-backup":
|
||||
ensure => present,
|
||||
content => template("postgresql/pgsql-backup.erb"),
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
require => File[$datadir],
|
||||
}
|
||||
|
||||
cron { "pgsql-backup":
|
||||
command => "/usr/local/sbin/pgsql-backup",
|
||||
environment => [ "MAILTO=root", ],
|
||||
user => "postgres",
|
||||
hour => "0",
|
||||
minute => "20",
|
||||
require => File["/usr/local/sbin/pgsql-backup"],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue