summaryrefslogtreecommitdiff
path: root/source4/selftest/provisions/dump.sh
blob: 3616d56b2846a8af2cc7d9cd7470fb51718997c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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