Skip to content
Snippets Groups Projects

add ldap backup with mdb backend

Merged Hahn Axel (hahn) requested to merge version-2 into master
1 file
+ 16
6
Compare changes
  • Side-by-side
  • Inline
+ 16
6
@@ -8,8 +8,9 @@
# Author: daniel.schueler@iml.unibe.ch
# Location: /root/bin/backup_ldap.sh
#
# This script is called by Cron and controlled by Puppet.
# --> Do not edit manualy!
# --------------------------------------------------------------------------------
# 2021-12-13 ..... v1.0 detect config path
# 2021-12-13 ah v1.0 detect config path
# ================================================================================
@@ -25,7 +26,13 @@ fi
SLAPCAT='/sbin/slapcat'
LDAP_CONF_DIR_PATH='/etc/openldap/slapd.d'
# detect config path
LDAP_CONF_DIR_PATH=/something/unknown
for mydir in /etc/openldap/slapd.d /etc/ldap/slapd.d
do
test -d $mydir && LDAP_CONF_DIR_PATH=$mydir
done
# --------------------------------------------------------------------------------
@@ -45,7 +52,7 @@ function dump_ldap(){
fetchrc
if [ $rc -ne 0 ]; then
echo ERROR during backup $LDAP_CONF_DIR_PATH
echo ERROR during backup $LDAP_CONF_DIR_PATH with DN $DN
else
echo Dump OK
compress_file $DUMPFILE
@@ -60,7 +67,8 @@ function doLdapBackup(){
create_targetdir
echo ----- LDAP BACKUP CONFIG
for cfgname in `ldapsearch -H ldap:// -x -s base -b "" -LLL "configContext" | grep "configContext" | cut -f 2 -d ":"`
# for cfgname in `ldapsearch -H ldap:// -x -s base -b "" -LLL "configContext" | grep "configContext" | cut -f 2 -d ":"`
for cfgname in `ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b '' -LLL configContext | grep "configContext" | cut -f 2 -d ":"`
do
echo DN $cfgname
cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"`
@@ -71,7 +79,8 @@ function doLdapBackup(){
echo ----- LDAP DATA
for cfgname in `ldapsearch -H ldap:// -x -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":"`
#for cfgname in `ldapsearch -H ldap:// -x -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":"`
for cfgname in `ldapsearch -Y EXTERNAL -H ldapi:/// -s base -b "" -LLL "namingContexts" | grep "namingContexts" | cut -f 2 -d ":"`
do
echo DN $cfgname
cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"`
@@ -103,6 +112,7 @@ j_requireBinary "slapcat" 1
j_requireProcess "slapd" 1
ls $LDAP_CONF_DIR_PATH >/dev/null
if [ $rc -ne 0 ]; then
rc=0
Loading