cope with file based configuration
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Fri, 30 Jan 2015 00:55:21 +0100
changeset 12 fb742f124b20
parent 11 c042fcdb85c9
child 13 124a3c3058ee
cope with file based configuration
ldap-backup
--- a/ldap-backup	Fri Jan 30 00:44:15 2015 +0100
+++ b/ldap-backup	Fri Jan 30 00:55:21 2015 +0100
@@ -9,7 +9,6 @@
 ME=$(basename $0)
 cf=/etc/$ME.conf
 
-
 if test -t 0; then
 	# terminal/interactive
 	destination=${1:?Need destination directory}
@@ -34,13 +33,18 @@
 mkdir "$dir"
 
 # save the config db
-slapcat -n 0 >"$dir"/cn=config.ldif
-
-grep olcSuffix: "$dir"/cn=config.ldif | cut -f2 -d' ' \
-	| while read suffix; do
-		slapcat -b "$suffix" > "$dir/$suffix.ldif"
-		tar czf "$destination"/"$dir".tar.gz.$$ "$dir"
-		mv "$destination"/"$dir".tar.gz.$$ \
-		   "$destination"/"$dir".tar.gz
+{
+	if test -d /etc/ldap/slapd.d
+	then
+		slapcat -n 0 >"$dir"/cn=config.ldif
+		grep olcSuffix: "$dir"/cn=config.ldif 
+	else
+		ldapsearch -s base -b '' -x -LLL namingContexts | grep ^namingContexts 
+	fi
+} | cut -f2 -d' ' | while read suffix; do
+	slapcat -b "$suffix" > "$dir/$suffix.ldif"
+	tar czf "$destination"/"$dir".tar.gz.$$ "$dir"
+	mv "$destination"/"$dir".tar.gz.$$ \
+	   "$destination"/"$dir".tar.gz
 
 done