]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-by-file-tape
Final changes
[bacula/bacula] / regress / tests / restore-by-file-tape
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory 
4 #   to a tape where the maximum tape file size is set to 1M
5 #   then restore a few files from it.  Note, by setting the maximum 
6 #   file size to 1M, it runs very slow. There are about 64 files that
7 #   are created during each of the two backups.
8 #
9 cwd=`pwd`
10 scripts/copy-tape-confs
11 scripts/cleanup-tape
12 echo "${cwd}/build" >/tmp/file-list
13 sed s%\^%${cwd}% ${cwd}/scripts/flist >${cwd}/tmp/restore2-list
14
15 cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
16 sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
17
18 echo " "
19 echo " "
20 echo " === Starting restore-by-file-tape test ==="
21 echo " === Starting restore-by-file-tape test ===" >>working/log
22 echo " "
23
24 bin/bacula start 2>&1 >/dev/null
25 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
26 @output /dev/null
27 messages
28 @output tmp/log1.out
29 label storage=DDS-4 volume=TestVolume001 slot=0
30 run job=NightlySave level=Full yes
31 wait
32 messages
33 @# 
34 @# now do a restore
35 @#
36 @output tmp/log2.out
37 restore where=${cwd}/tmp/bacula-restores storage=DDS-4 file=<${cwd}/tmp/restore2-list
38 yes
39 wait
40 messages
41 @output
42 quit
43 END_OF_DATA
44 dstat=0
45 scripts/check_for_zombie_jobs storage=DDS-4
46 #
47 # We need to stop and start Bacula to
48 #  test appending to a previously written tape
49 #
50 bin/bacula stop  2>&1 >/dev/null
51 bin/bacula start 2>&1 >/dev/null
52 for i in `cat ${cwd}/tmp/restore2-list`; do
53    diff $i ${cwd}/tmp/bacula-restores$i
54    if [ $? != 0 ] ; then
55       dstat=1
56    fi
57 done
58 grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
59 bstat=$?
60 grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
61 rstat=$?
62 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
63    echo " "
64    echo " "
65    echo "  !!!!! restore-by-file-tape test Bacula source failed!!! !!!!! "
66    echo "  !!!!! restore-by-file-tape test failed!!! !!!!! " >>test.out
67    echo " "
68    bin/bacula stop 2>&1 >/dev/null
69    exit 1
70 else
71    echo "  First of two restores OK "
72 fi
73 rm -rf ${cwd}/tmp/bacula-restores
74 #
75 # Now do a second backup and restore
76 #
77 bin/bconsole -c bin/bconsole.conf <<END_OF_DATA
78 @output /dev/null
79 messages
80 @output tmp/log1.out
81 run job=NightlySave level=Full yes
82 wait
83 messages
84 @#
85 @# now do a restore
86 @#
87 @output tmp/log2.out
88 restore where=${cwd}/tmp/bacula-restores
89 7
90 <${cwd}/tmp/restore2-list
91                                                                                         
92 yes
93 wait
94 messages
95 @output
96 quit
97 END_OF_DATA
98 scripts/check_for_zombie_jobs storage=DDS-4
99 bin/bacula stop 2>&1 >/dev/null
100 for i in `cat ${cwd}/tmp/restore2-list`; do
101    diff $i ${cwd}/tmp/bacula-restores$i
102    if [ $? != 0 ] ; then
103       dstat=1
104    fi
105 done
106 grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
107 bstat=$?
108 grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
109 rstat=$?
110 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
111    echo " "
112    echo " "
113    echo "  !!!!! restore-by-file-tape test Bacula source failed!!! !!!!! "
114    echo "  !!!!! restore-by-file-tape test failed!!! !!!!! " >>test.out
115    echo " "
116 else
117    echo "  ===== restore-by-file-tape test Bacula source OK ===== "
118    echo "  ===== restore-by-file-tape test OK ===== " >>test.out
119 #  scripts/cleanup
120 fi