]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/bpipe-test
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / tests / bpipe-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 #
7 # Attempt to backup and restore a file with the bpipe plugin
8 #
9 TestName="bpipe-test"
10 JobName=pluginTest
11 . scripts/functions
12
13 scripts/cleanup
14 scripts/copy-plugin-confs
15
16 file=encrypt-bug.jpg
17 rm -rf ${cwd}/tmp/*
18 echo "${cwd}/README" >${cwd}/tmp/file-list
19
20 start_test
21
22 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
23 @output /dev/null
24 messages
25 @$out ${cwd}/tmp/log1.out
26 label storage=File1 volume=TestVolume001
27 estimate job=$JobName level=Full
28 @#setdebug level=50 traclient=$CLIENT
29 run job=$JobName storage=File1 yes
30 wait
31 @#setdebug level=50 client=$CLIENT
32 run job=$JobName storage=File1 yes
33 wait
34 status client=$CLIENT
35 messages
36 quit
37 END_OF_DATA
38
39
40 run_bacula
41
42 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
43 @$out $tmp/files
44 list files jobid=1
45 list files jobid=2
46 @$out $tmp/list
47 llist pluginrestoreconf jobid=1
48 llist pluginrestoreconf jobid=2
49 @$out $tmp/conf
50 llist pluginrestoreconf jobid=1 id=1
51 llist pluginrestoreconf jobid=1 id=2
52 END_OF_DATA
53
54 run_bconsole
55
56 nb=`grep Makefile $tmp/files | wc -l`
57 if [ $nb -ne 2 ]; then
58     print_debug "ERROR: Should have two times Makefile in job files $tmp/files"
59     bstat=1
60 fi
61
62 nb=`grep $file $tmp/files | wc -l`
63 if [ $nb -ne 2 ]; then
64     print_debug "ERROR: Should have two times $file in job files $tmp/files"
65     bstat=1
66 fi
67
68 nb=`grep README $tmp/files | wc -l`
69 if [ $nb -ne 1 ]; then
70     print_debug "ERROR: Should have one time README in job files $tmp/files"
71     bstat=1
72 fi
73
74 nb=`grep $file $tmp/list | wc -l`
75 if [ $nb -ne 1 ]; then
76     print_debug "ERROR: Should find the RestoreObject for $file in $tmp/list"
77     bstat=1
78 fi
79
80 nb=`grep Makefile $tmp/list | wc -l`
81 if [ $nb -ne 1 ]; then
82     print_debug "ERROR: Should find the RestoreObject for Makefile in $tmp/list"
83     bstat=1
84 fi
85
86 nb=`grep restore_command $tmp/conf | wc -l`
87 if [ $nb -ne 2 ]; then
88     print_debug "ERROR: Should find the RestoreObject for Makefile and $file in $tmp/conf"
89     bstat=1
90 fi
91
92 cat <<EOF >$tmp/obj
93 restore_command="cat >$tmp/Makefile.bak"
94 EOF
95
96 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
97 messages
98 @# 
99 @# now do a restore
100 @#
101 @$out ${cwd}/tmp/log3.out
102 setdebug level=50 client=$CLIENT trace=1
103 @putfile obj1 $tmp/obj
104 restore pluginrestoreconf="2:obj1" where=${cwd}/tmp  select all storage=File1 done
105 yes
106 wait
107 setdebug level=0 client=$CLIENT trace=0
108 messages
109 quit
110 END_OF_DATA
111
112 run_bconsole
113
114 #
115 # Remove plugin so we can try the restore without the plugin
116 #
117 mv -f ${cwd}/bin/plugins/bpipe-fd.so ${cwd}/bin/plugins/bpipe-fd.sox
118
119 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
120 @$out ${cwd}/tmp/log2.out
121 @# 
122 @# now do a restore without the plugin
123 @#
124 @$out ${cwd}/tmp/log2.out
125 @#setdebug level=50 client=$CLIENT
126 restore where=${cwd}/tmp  select all storage=File1 done
127 yes
128 wait
129 messages
130 quit
131 END_OF_DATA
132
133 stop_bacula
134 run_bacula -d50
135 run_bconsole
136
137 check_for_zombie_jobs storage=File1
138 stop_bacula
139 #
140 # Restore plugin
141 #
142 mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so
143
144 check_two_logs
145 #
146 # ****FIXME**** test that all three files are restored correctly
147 #
148 diff ${cwd}/Makefile ${cwd}/tmp/Makefile.bak
149 dstat=$?
150
151 diff ${cwd}/${file} ${cwd}/tmp/${file}
152 dstat=$(($dstat + $?))
153
154 diff ${cwd}/tmp/@bpipe@/${file} ${cwd}/${file}
155 dstat=$(($dstat + $?))
156
157 diff ${cwd}/tmp/@bpipe@/Makefile ${cwd}/Makefile
158 dstat=$(($dstat + $?))
159
160 end_test