selftest: Add script to assist in writing out a tree undump.sh can restore
authorAndrew Bartlett <abartlet@samba.org>
Sun, 22 Sep 2013 01:52:21 +0000 (18:52 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 22 Sep 2013 21:39:50 +0000 (14:39 -0700)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source4/selftest/provisions/dump.sh [new file with mode: 0755]

diff --git a/source4/selftest/provisions/dump.sh b/source4/selftest/provisions/dump.sh
new file mode 100755 (executable)
index 0000000..3616d56
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+# dump a provision directory
+
+[ "$#" -gt 0 ] || {
+    echo "Usage: dump.sh <DIRECTORY> [TARGETDIR] [TDBDUMP]"
+    exit 1
+}
+
+TDBDUMP=tdbdump
+[ "$#" -lt 3 ] || {
+    TDBDUMP=$3
+}
+
+
+dirbase="$1"
+
+TARGETDIR=`pwd`/$dirbase
+
+cd $dirbase
+
+[ "$#" -lt 2 ] || {
+    TARGETDIR=$2
+}
+
+for f in $(find . -name '*.tdb'); do
+    dname=$TARGETDIR/$(dirname $f)
+    mkdir -p $dname
+    outname=$f.dump
+    echo "Dumping $f to $outname"
+    $TDBDUMP $f > $outname || {
+       echo "Failed to dump to $outname"
+       exit 1
+    }
+    rm -f $f
+done
+
+for f in $(find . -name '*.ldb'); do
+    dname=$TARGETDIR/$(dirname $f)
+    mkdir -p $dname
+    outname=$f.dump
+    echo "Dumping $f to $outname"
+    $TDBDUMP $f > $outname || {
+       echo "Failed to dump to $outname"
+       exit 1
+    }
+    rm -f $f
+done
+exit 0