]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/relabel-tape
commit changes
[bacula/bacula] / regress / tests / relabel-tape
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory using the compressed option
4 #   then backup four times, each with incremental then finally restore.
5 #   It should require at least 4 different bsrs.
6 #
7 debug=0
8 if test "$debug" -eq 1 ; then
9   out="tee"
10 else
11   out="output"
12 fi
13
14 cwd=`pwd`
15 scripts/copy-tape-confs
16 scripts/cleanup-tape
17 echo "${cwd}/build" >/tmp/file-list
18
19 echo " "
20 echo " "
21 echo " === Starting relabel-tape at `date +%R:%S` ==="
22 echo " === Starting relabel-tape at `date +%R:%S` ===" >>working/log
23 echo " "
24
25 cat <<END_OF_DATA >tmp/bconcmds
26 @output /dev/null
27 messages
28 @$out tmp/log1.out
29 label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
30 run job=NightlySave level=Full yes
31 wait
32 messages
33 add pool=Default
34 0
35 TestVolume002
36 @# set status to append
37 update volume=TestVolume001
38 1
39 .
40 run job=NightlySave level=Full yes
41 @sleep 20
42 unmount
43 unmount
44 purge volume=TestVolume001
45 relabel oldvolume=TestVolume001 volume=TestVolume003 slot=0 pool=Default
46 list volumes
47 mount
48 messages
49 wait
50 run job=NightlySave level=Full yes
51 wait
52 messages
53 @$out
54 quit
55 END_OF_DATA
56
57 if test "$debug" -eq 1 ; then
58   bin/bacula start
59   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
60 else
61   bin/bacula start 2>&1 >/dev/null
62   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
63 fi
64
65 echo "Backup done"
66
67 # now do several restores to ensure we cleanup between jobs
68 #
69 cat <<END_OF_DATA >tmp/bconcmds
70 @$out /dev/null
71 restore where=${cwd}/tmp/bacula-restores select all done
72 yes
73 wait
74 restore where=${cwd}/tmp/bacula-restores select all done
75 yes
76 wait
77 @$out tmp/log2.out
78 @#
79 @# now unmount the tape and start two restores
80 @#  at the same time
81 @#
82 unmount storage=DDS-4
83 restore where=${cwd}/tmp/bacula-restores select all done
84 yes
85 restore where=${cwd}/tmp/bacula-restores select
86 unmark *
87 mark *
88 done
89 yes
90 mount storage=DDS-4
91 wait
92 messages
93 @$out
94 quit
95 END_OF_DATA
96
97 if test "$debug" -eq 1 ; then
98   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
99 else
100   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
101 fi
102
103 scripts/check_for_zombie_jobs storage=DDS-4
104 bin/bacula stop 2>&1 >/dev/null
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 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
110 dstat=$?
111 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
112    echo " "
113    echo " "
114    echo "  !!!!! relabel-tape Bacula source failed!!! !!!!! "
115    echo "  !!!!! relabel-tape failed!!! !!!!! " >>test.out
116    echo "diff=$dstat backup=$bstat restore=$rstat"
117    echo " "
118 else
119    echo "  ===== relabel-tape Bacula source OK ===== "
120    echo "  ===== relabel-tape OK ===== " >>test.out
121    scripts/cleanup
122 fi