]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-by-file-tape
35e0b2e3634aa8734ee8240ef40825aaf97e6337
[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.
6 #
7 cwd=`pwd`
8 bin/bacula stop  2>&1 >/dev/null
9 scripts/copy-tape-confs
10 scripts/cleanup-tape
11 echo "${cwd}/build" >/tmp/file-list
12 sed s%\^%${cwd}% ${cwd}/scripts/flist >${cwd}/tmp/restore2-list
13 bin/drop_sqlite_tables
14 bin/make_sqlite_tables
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
38 7
39 <${cwd}/tmp/restore2-list
40
41 yes
42 wait
43 messages
44 @output
45 quit
46 END_OF_DATA
47 dstat=0
48 #
49 # We need to stop and start Bacula to
50 #  test appending to a previously written tape
51 #
52 bin/bacula stop  2>&1 >/dev/null
53 bin/bacula start 2>&1 >/dev/null
54 for i in `cat ${cwd}/tmp/restore2-list`; do
55    diff $i ${cwd}/tmp/bacula-restores$i
56    if [ $? != 0 ] ; then
57       dstat=1
58    fi
59 done
60 grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
61 bstat=$?
62 grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
63 rstat=$?
64 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
65    echo " "
66    echo " "
67    echo "  !!!!! restore-by-file-tape test Bacula source failed!!! !!!!! "
68    echo "  !!!!! restore-by-file-tape test failed!!! !!!!! " >>test.out
69    echo " "
70    bin/bacula stop 2>&1 >/dev/null
71    exit 1
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 bin/bacula stop 2>&1 >/dev/null
99 for i in `cat ${cwd}/tmp/restore2-list`; do
100    diff $i ${cwd}/tmp/bacula-restores$i
101    if [ $? != 0 ] ; then
102       dstat=1
103    fi
104 done
105 grep "^Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
106 bstat=$?
107 grep "^Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
108 rstat=$?
109 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
110    echo " "
111    echo " "
112    echo "  !!!!! restore-by-file-tape test Bacula source failed!!! !!!!! "
113    echo "  !!!!! restore-by-file-tape test failed!!! !!!!! " >>test.out
114    echo " "
115 else
116    echo "  ===== restore-by-file-tape test Bacula source OK ===== "
117    echo "  ===== restore-by-file-tape test OK ===== " >>test.out
118 #  scripts/cleanup
119 fi