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