]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/incremental-2disk
Update
[bacula/bacula] / regress / tests / incremental-2disk
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then create some           
4 #   new files, do an Incremental and restore those two files.
5 #
6 # This script uses the virtual disk autochanger
7 #
8 . config.out
9 if test x${AUTOCHANGER} = x/dev/null ; then
10    echo "incremental-2disk test skipped. No autochanger."
11    exit
12 fi
13 debug=0
14 if test "$debug" -eq 1 ; then
15   out="tee"
16 else
17   out="output"
18 fi
19 cwd=`pwd`
20 bin/bacula stop  2>&1 >/dev/null
21 cd bin
22 ./drop_bacula_tables >/dev/null 2>&1
23 ./make_bacula_tables >/dev/null 2>&1
24 ./grant_bacula_privileges 2>&1 >/dev/null
25 cd ..
26
27 scripts/copy-2disk-confs
28 scripts/prepare-two-disks
29
30 echo "${cwd}/tmp/build" >/tmp/file-list
31 if test ! -d ${cwd}/tmp/build ; then
32    mkdir ${cwd}/tmp/build
33 fi
34 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
35 cd ${cwd}/tmp
36 echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
37 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
38 cd ${cwd}
39
40 echo " "
41 echo " "
42 echo " === Starting incremental-2disk test ==="
43 echo " === Starting incremental-2disk test ===" >>working/log
44 echo " "
45
46 # Write out bconsole commands
47 cat <<END_OF_DATA >tmp/bconcmds
48 @$out /dev/null
49 messages
50 @$out tmp/log1.out
51 label storage=DDS-4 volume=TestVolume001 slot=1 Pool=Default drive=0
52 label storage=DDS-4 volume=TestVolume002 slot=2 Pool=Default drive=0
53 run job=NightlySave yes
54 wait
55 messages
56 quit
57 END_OF_DATA
58
59 if test "$debug" -eq 1 ; then
60   bin/bacula start
61   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
62 else
63   bin/bacula start 2>&1 >/dev/null
64   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
65 fi
66 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
67 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
68 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
69 @$out /dev/null
70 messages
71 @$out tmp/log1.out
72 @# Force Incremental on the second Volume
73 update volume=TestVolume001 VolStatus=Used
74 run level=Incremental job=NightlySave yes
75 wait
76 messages
77 @# 
78 @# now do a restore
79 @#
80 @$out tmp/log2.out
81 restore where=${cwd}/tmp/bacula-restores 
82 7
83 <${cwd}/tmp/restore-list
84
85 yes
86 wait
87 messages
88 @$out
89 quit
90 END_OF_DATA
91 bin/bacula stop 2>&1 >/dev/null
92 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
93 bstat=$?
94 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
95 rstat=$?
96 #
97 # Delete .c files because we will only restored the txt files
98 #
99 rm -f tmp/build/*.c
100 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
101 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
102    echo " "
103    echo " "
104    echo "  !!!!! incremental-2disk test Bacula source failed!!! !!!!! "
105    echo "  !!!!! incremental-2disk test failed!!! !!!!! " >>test.out
106    echo " "
107 else
108    echo "  ===== incremental-2disk test Bacula source OK ===== "
109    echo "  ===== incremental-2disk test OK ===== " >>test.out
110    scripts/cleanup
111 fi