--- 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