diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:35:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:35:33 +0000 |
commit | 1f641814b2bfbbf2dc3347e11a3fe901bfdf1efc (patch) | |
tree | 77094b19bf9091ceb6f6ab7d0267f70fef9c8323 /debian/slapd.backup | |
parent | Adding upstream version 2.5.13+dfsg. (diff) | |
download | openldap-debian.tar.xz openldap-debian.zip |
Adding debian version 2.5.13+dfsg-5.debian/2.5.13+dfsg-5debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/slapd.backup')
-rw-r--r-- | debian/slapd.backup | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/debian/slapd.backup b/debian/slapd.backup new file mode 100644 index 0000000..4046f8c --- /dev/null +++ b/debian/slapd.backup @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Backup LDAP directories +# +# This script can be put in cron to create backups. +# +# Author: Matthijs Mohlmann <matthijs@cacholong.nl> +# Date: Sat, 15 Jul 2006 21:13:14 +0200 +# License: GPLv2 + +# Make sure the backups are secured. +umask 077 + +BACKUPDIR="/var/backups/slapd" +DEFAULTS="/etc/default/slapd" + +# Check if there is a directory slapd, otherwise create it. +if [ ! -d "$BACKUPDIR" ]; then + mkdir -p -m 0700 "$BACKUPDIR" +fi + +# Load default settings. +if [ -e "$DEFAULTS" ]; then + . "$DEFAULTS" +fi + +# Specify a slapd.conf if not specified. +if [ -z "$SLAPD_CONF" ]; then + SLAPD_CONF="/etc/ldap/slapd.conf" +fi + +# Set IFS to end of line. +ORIGIFS=$IFS +IFS=`echo -en "\n\b"` + +# Backup recursive through all configfiles all suffix's in the form: +# suffix.ldif in /var/backups/slapd +function backupDirectories() { + local conf=$1 + local directory="" + local include="" + + suffix=`grep "^suffix" $conf | sed -e "s/\(^suffix\s\+\|\"\|\'\)//g"` + for directory in "$suffix"; do + if [ ! -z "$suffix" ]; then + slapcat -l "$BACKUPDIR/$suffix.ldif" -b "$suffix" + fi + done + + includes=`grep "^include" $conf | awk '{print $2}'` + for include in $includes; do + backupDirectories "$include" + done +} + +backupDirectories "$SLAPD_CONF" + +# Put IFS back. +IFS=$ORIGIFS + +exit 0 + |