summaryrefslogtreecommitdiff
path: root/source4/selftest/provisions/undump.sh
blob: 7ffea3eff70af927455fcd2a006e213276b1e76b (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
#!/bin/sh
# undump a provision directory

[ "$#" -gt 0 ] || {
    echo "Usage: undump.sh <DIRECTORY> [TARGETDIR] [TDBRESTORE]"
    exit 1
}

TDBRESTORE=tdbrestore
[ "$#" -lt 3 ] || {
    TDBRESTORE=$3
}


dirbase="$1"

TARGETDIR=`pwd`/$dirbase

cd $dirbase

[ "$#" -lt 2 ] || {
    TARGETDIR=$2
}

for f in $(find . -name '*.dump'); do
    dname=$TARGETDIR/$(dirname $f)
    mkdir -p $dname
    bname=$(basename $f .dump)
    outname=$dname/$bname
    echo "Restoring $outname"
    rm -f $outname
    $TDBRESTORE $outname < $f || {
	echo "Failed to restore $outname"
	exit 1
    }
done
exit 0