Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Added a class to manage a backup script #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions manifests/server/backup.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# == Class: ldap::server::backup
#
# Class to manage OpenLDAP Backup.
#
#
# === Parameters
#
# [ensure]
# *Optional* (defaults to 'present')
#
# [backup_path]
# *Optional* (defaults to /var/backups/ldap)
#
# [backup_dbs]
# *Optional* Hash that specifies the databases to Backup
# in the format: DBnumber => backup_filename.ldif


class ldap::server::backup (
$ensure = present,
$backup_path = '/var/backups/ldap',
$backup_dbs = { 0 => 'config.ldif',
1 => 'domain.ldif' }
) {

if !defined (Class['Ldap::Server::Master']) and !defined ( Class['Ldap::Server::Slave']) {
fail('You must include ldap::server::master or ldap::server::slave before ldap::server::backup.')
}

require ldap

file { $backup_path:
ensure => $ensure ? {
present => 'directory',
default => $ensure,
},
mode => '0640',
owner => 'root',
group => $ldap::params::server_group,
}

file { "${ldap::params::prefix}/ldapbackup.sh":
ensure => $ensure,
mode => 'ug+x',
owner => 'root',
group => $ldap::params::server_group,
content => template("ldap/${ldap::params::prefix}/ldapbackup.sh.erb"),
}

}
1 change: 1 addition & 0 deletions templates/etc/ldap/ldapbackup.sh.erb
9 changes: 9 additions & 0 deletions templates/etc/openldap/ldapbackup.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

BACKUP_PATH=<%= @backup_path %>
SLAPCAT=`which slapcat`

<% @backup_dbs.each_pair do |key, value| -%>
nice ${SLAPCAT} -n <%= key %> > ${BACKUP_PATH}/<%= value %>
<% end -%>
chmod 640 ${BACKUP_PATH}/*.ldif