Skip to content
Snippets Groups Projects
Commit 01c17f74 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'version-2' into 'master'

add ldap backup with mdb backend

See merge request !19
parents 97d6b672 11011f7c
Branches
No related tags found
1 merge request!19add ldap backup with mdb backend
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
# Author: daniel.schueler@iml.unibe.ch # Author: daniel.schueler@iml.unibe.ch
# Location: /root/bin/backup_ldap.sh # 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 ...@@ -25,7 +26,13 @@ fi
SLAPCAT='/sbin/slapcat' 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(){ ...@@ -45,7 +52,7 @@ function dump_ldap(){
fetchrc fetchrc
if [ $rc -ne 0 ]; then 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 else
echo Dump OK echo Dump OK
compress_file $DUMPFILE compress_file $DUMPFILE
...@@ -60,7 +67,8 @@ function doLdapBackup(){ ...@@ -60,7 +67,8 @@ function doLdapBackup(){
create_targetdir create_targetdir
echo ----- LDAP BACKUP CONFIG 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 do
echo DN $cfgname echo DN $cfgname
cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"` cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"`
...@@ -71,7 +79,8 @@ function doLdapBackup(){ ...@@ -71,7 +79,8 @@ function doLdapBackup(){
echo ----- LDAP DATA 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 do
echo DN $cfgname echo DN $cfgname
cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"` cfg2=`echo $cfgname | sed "s#[\ =,]#_#g"`
...@@ -103,6 +112,7 @@ j_requireBinary "slapcat" 1 ...@@ -103,6 +112,7 @@ j_requireBinary "slapcat" 1
j_requireProcess "slapd" 1 j_requireProcess "slapd" 1
ls $LDAP_CONF_DIR_PATH >/dev/null
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
rc=0 rc=0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment