]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/backup-bacula-tape
Final changes
[bacula/bacula] / regress / tests / backup-bacula-tape
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory 
4 #   to a tape then restore it, we do that twice to ensure that
5 #   we can correctly append to a tape.
6 # We also use the purge and the relabel commands as
7 #   well as a pile of status storage commands.
8 #
9 debug=0 
10 if test "$debug" -eq 1 ; then
11   out="tee"
12 else
13   out="output"
14 fi
15
16 cwd=`pwd`
17 scripts/copy-tape-confs
18 scripts/cleanup-tape
19
20 echo "${cwd}/build" >/tmp/file-list
21
22 echo " "
23 echo " "
24 echo " === Starting Backup Bacula tape test at `date +%R:%S` ==="
25 echo " === Starting Backup Bacula tape test at `date +%R:%S` ===" >>working/log
26 echo " "
27
28 # Write out bconsole commands
29 cat <<END_OF_DATA >tmp/bconcmds
30 @output /dev/null
31 messages
32 @$out tmp/log1.out
33 label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
34 purge volume=TestVolume001
35 relabel pool=Default storage=DDS-4 oldVolume=TestVolume001 volume=TestVolume002 slot=0
36 purge volume=TestVolume002
37 relabel pool=Default storage=DDS-4 oldVolume=TestVolume002 volume=TestVolume001 slot=0
38 run job=NightlySave yes
39 status storage=DDS-4
40 status storage=DDS-4
41 status storage=DDS-4
42 status storage=DDS-4
43 status storage=DDS-4
44 status storage=DDS-4
45 @sleep 1
46 status storage=DDS-4
47 status storage=DDS-4
48 status storage=DDS-4
49 status storage=DDS-4
50 status storage=DDS-4
51 @sleep 1
52 status storage=DDS-4
53 status storage=DDS-4
54 status storage=DDS-4
55 status storage=DDS-4
56 status storage=DDS-4
57 @sleep 1
58 status storage=DDS-4
59 status storage=DDS-4
60 status storage=DDS-4
61 status storage=DDS-4
62 status storage=DDS-4
63 @sleep 1
64 status storage=DDS-4
65 status storage=DDS-4
66 status storage=DDS-4
67 status storage=DDS-4
68 status storage=DDS-4
69 wait
70 messages
71 @# 
72 @# now do a restore
73 @#
74 @$out tmp/log2.out
75 restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
76 yes
77 wait
78 list volumes
79 messages
80 END_OF_DATA
81
82 if test "$debug" -eq 1 ; then
83   bin/bacula start
84   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
85 else
86   bin/bacula start 2>&1 >/dev/null
87   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
88 fi
89
90 bin/bacula stop 2>&1 >/dev/null
91 #
92 # Now do a second backup after making a few changes
93 #
94 touch ${cwd}/build/src/dird/*.c
95 echo "test test" > ${cwd}/build/src/dird/xxx
96
97 cat <<END_OF_DATA >tmp/bconcmds
98 @$out /dev/null
99 messages
100 @$out tmp/log1.out
101 list volumes
102 run job=NightlySave yes
103 wait
104 list volumes
105 messages
106 @# 
107 @# now do a second restore
108 @#
109 @$out tmp/log2.out
110 list volumes
111 restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
112 yes
113 wait
114 list volumes
115 messages
116 @$out
117 quit
118 END_OF_DATA
119
120 if test "$debug" -eq 1 ; then
121   bin/bacula start
122   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
123 else
124   bin/bacula start 2>&1 >/dev/null
125   cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf  2>&1 >/dev/null
126 fi
127 scripts/check_for_zombie_jobs storage=DDS-4
128
129 bin/bacula stop 2>&1 >/dev/null
130 grep "^  Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
131 bstat=$?
132 grep "^  Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
133 rstat=$?
134 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
135 if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
136    echo " "
137    echo " "
138    echo "  !!!!! Backup Bacula tape test failed!!! !!!!! "
139    echo "  !!!!! Backup Bacula tape test failed!!! !!!!! " >>test.out
140    echo " "
141 else
142    echo "  ===== Backup Bacula tape test OK ===== "
143    echo "  ===== Backup Bacula tape test OK ===== " >>test.out
144    scripts/cleanup
145 fi