summaryrefslogtreecommitdiffstats
path: root/roles/common-LDAP/files/usr/local
diff options
context:
space:
mode:
Diffstat (limited to 'roles/common-LDAP/files/usr/local')
-rwxr-xr-xroles/common-LDAP/files/usr/local/sbin/slapcat-all.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/roles/common-LDAP/files/usr/local/sbin/slapcat-all.sh b/roles/common-LDAP/files/usr/local/sbin/slapcat-all.sh
new file mode 100755
index 0000000..4e5b5e4
--- /dev/null
+++ b/roles/common-LDAP/files/usr/local/sbin/slapcat-all.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Usage: slapcat-all.sh DIR
+# Save all LDAP databases in DIR: DIR/0.ldif, DIR/1.ldif, ...
+
+set -ue
+PATH=/usr/sbin:/sbin:/usr/bin:/bin
+
+target="$1"
+umask 0077
+
+slapcat -n0 -l"$target/0.ldif"
+n=$(grep -Ec '^dn:\s+olcDatabase={[1-9][0-9]*}' "$target/0.ldif")
+
+while [ $n -gt 0 ]; do
+ slapcat -n$n -l"$target/$n.ldif"
+ n=$(( $n - 1 ))
+done