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