]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/relabel-tape
Updates
[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 @$out /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 0
37 no
38 update volume=TestVolume001
39 1
40
41 .
42 run job=NightlySave level=Full yes
43 @sleep 20
44 unmount
45 unmount
46 purge volume=TestVolume001
47 relabel oldvolume=TestVolume001 volume=TestVolume003 slot=0 pool=Default
48 list volumes
49 messages
50 wait
51 messages
52 @$out
53 quit
54 END_OF_DATA
55
56 if test "$debug" -eq 1 ; then
57   bin/bacula start
58   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
59 else
60   bin/bacula start 2>&1 >/dev/null
61   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
62 fi
63
64 echo "Backup done"
65
66 # now do several restores to ensure we cleanup between jobs
67 #
68 cat <<END_OF_DATA >tmp/bconcmds
69 @$out /dev/null
70 restore where=${cwd}/tmp/bacula-restores select all done
71 yes
72 wait
73 restore where=${cwd}/tmp/bacula-restores select all done
74 yes
75 wait
76 @$out tmp/log2.out
77 @#
78 @# now unmount the tape and start two restores
79 @#  at the same time
80 @#
81 unmount storage=DDS-4
82 restore where=${cwd}/tmp/bacula-restores select all done
83 yes
84 restore where=${cwd}/tmp/bacula-restores select
85 unmark *
86 mark *
87 done
88 yes
89 mount storage=DDS-4
90 wait
91 messages
92 @$out
93 quit
94 END_OF_DATA
95
96 if test "$debug" -eq 1 ; then
97   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
98 else
99   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
100 fi
101
102 scripts/check_for_zombie_jobs storage=DDS-4
103 bin/bacula stop 2>&1 >/dev/null
104 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
105 bstat=$?
106 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
107 rstat=$?
108 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
109 dstat=$?
110 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
111    echo " "
112    echo " "
113    echo "  !!!!! relabel-tape Bacula source failed!!! !!!!! "
114    echo "  !!!!! relabel-tape failed!!! !!!!! " >>test.out
115    echo "diff=$dstat backup=$bstat restore=$rstat"
116    echo " "
117 else
118    echo "  ===== relabel-tape Bacula source OK ===== "
119    echo "  ===== relabel-tape OK ===== " >>test.out
120    scripts/cleanup
121 fi