]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-by-file-test
Update
[bacula/bacula] / regress / tests / restore-by-file-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory using the compressed option
4 #   then restore it.
5 #
6
7 debug=0
8 if test "$debug" -eq 1 ; then
9   out="tee"
10 else
11   out="output"
12 fi
13 cwd=`pwd`
14 scripts/copy-test-confs
15 scripts/cleanup
16 echo "${cwd}/tmp/build" >/tmp/file-list
17 mkdir ${cwd}/tmp/build
18 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
19 cd ${cwd}/tmp/build
20 ls >../1
21 cd ..
22 sed s%\^%${cwd}/tmp/build/% 1 >restore-list
23 rm -f 1
24 cd ${cwd}
25
26 echo " "
27 echo " "
28 echo " === Starting restore-by-file-test at `date +%R:%S` ==="
29 echo " === Starting restore-by-file-test at `date +%R:%S` ===" >>working/log
30 echo " "
31
32 cat <<END_OF_DATA >tmp/bconcmds
33 @output /dev/null
34 messages
35 @$out tmp/log1.out
36 label storage=File volume=TestVolume001
37 run job=CompressedTest yes
38 wait
39 messages
40 @# 
41 @# now do a restore
42 @#
43 @$out tmp/log2.out
44 restore where=${cwd}/tmp/bacula-restores storage=File
45 7
46 <${cwd}/tmp/restore-list
47
48 yes
49 wait
50 messages
51 @$out
52 quit
53 END_OF_DATA
54
55 if test "$debug" -eq 1 ; then
56   bin/bacula start
57   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
58 else
59   bin/bacula start 2>&1 >/dev/null
60   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
61 fi
62
63 scripts/check_for_zombie_jobs storage=File
64 bin/bacula stop 2>&1 >/dev/null
65 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
66 bstat=$?
67 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
68 rstat=$?
69 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
70 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
71    echo " "
72    echo " "
73    echo "  !!!!! restore-by-file-test Bacula source failed!!! !!!!! "
74    echo "  !!!!! restore-by-file-test failed!!! !!!!! " >>test.out
75    if [ $bstat != 0 -o $rstat != 0 ] ; then
76       echo "  !!!!! Bad Job termination status     !!!!! "
77       echo "  !!!!! Bad Job termination status     !!!!! " >>test.out
78    else
79       echo "  !!!!! Restored files differ          !!!!! "
80       echo "  !!!!! Restored files differ          !!!!! " >>test.out
81    fi
82    echo " "
83 else
84    echo "  ===== restore-by-file-test Bacula source OK ===== "
85    echo "  ===== restore-by-file-test OK ===== " >>test.out
86    scripts/cleanup
87 fi