]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/2drive-incremental-2disk
ebl Add multiple command test for runscript
[bacula/bacula] / regress / tests / 2drive-incremental-2disk
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then create some           
4 #   new files, do an Incremental and restore those two files.
5 #
6 # This script uses the virtual disk autochanger and two drives
7 #
8 TestName="2drive-incremental-2disk"
9 JobName="2drive2disk"
10 . scripts/functions
11
12 scripts/cleanup
13 scripts/copy-2disk-drive-confs
14 scripts/prepare-disk-changer
15 CLIENT=2drive2disk
16
17 change_jobname localhost-fd $JobName
18 start_test
19
20 echo "${cwd}/tmp/build" >${cwd}/tmp/file-list
21 if test ! -d ${cwd}/tmp/build ; then
22    mkdir ${cwd}/tmp/build
23 fi
24 cp -p ${cwd}/build/src/dird/*.c ${cwd}/tmp/build
25 cd ${cwd}/tmp
26 echo "${cwd}/tmp/build/ficheriro1.txt" >restore-list
27 echo "${cwd}/tmp/build/ficheriro2.txt" >>restore-list
28 cd ${cwd}
29
30 # Turn off Prefer Mounted Volumes so we use 2 drives
31 outf="${cwd}/tmp/sed_tmp"
32 echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
33 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
34 # Comment the next line out to write everything to one drive
35 #  otherwise, it writes the two jobs to different drives
36 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
37
38 # Write out bconsole commands
39 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
40 @output /dev/null
41 messages
42 @$out ${cwd}/tmp/log1.out
43 setdebug level=3 dir
44 setdebug level=3 storage=DDS-4
45 setdebug level=3 client=2drive2disk 
46 label storage=DDS-4 volume=TestVolume001 slot=1 Pool=Default drive=0
47 label storage=DDS-4 volume=TestVolume002 slot=2 Pool=Default drive=1
48 status storage=DDS-4
49 setdebug level=200 storage=DDS-4
50 run job=NightlySave yes
51 run job=NightlySave yes
52 run job=NightlySave yes
53 run job=NightlySave yes
54 run job=NightlySave yes
55 wait jobid=2
56 status storage=DDS-4
57 list volumes
58 list jobs
59 messages
60 wait
61 list volumes
62 list jobs
63 status storage=DDS-4
64 messages
65 quit
66 END_OF_DATA
67
68 run_bacula
69 echo "ficheriro1.txt" >${cwd}/tmp/build/ficheriro1.txt
70 echo "ficheriro2.txt" >${cwd}/tmp/build/ficheriro2.txt
71
72
73 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
74 @$out /dev/null
75 messages
76 @$out ${cwd}/tmp/log1.out
77 @# Force Incremental on the second Volume
78 update volume=TestVolume001 VolStatus=Used
79 status storage=DDS-4
80 list volumes
81 @#setdebug level=120 storage=DDS-4
82 run level=Incremental job=NightlySave yes
83 wait
84 list volumes
85 status storage=DDS-4
86 messages
87 @# 
88 @# now do a restore
89 @#
90 @$out ${cwd}/tmp/log2.out
91 restore where=${cwd}/tmp/bacula-restores 
92 7
93 <${cwd}/tmp/restore-list
94
95 yes
96 wait
97 messages
98 @$out
99 quit
100 END_OF_DATA
101
102 run_bconsole
103
104 check_for_zombie_jobs storage=DDS-4
105
106 stop_bacula
107
108 check_two_logs
109 # The restore should read from TestVolume002, which was on drive 1
110 grep TestVolume002 ${cwd}/tmp/log2.out >/dev/null 2>&1
111 # Note rstat may already be set, so we don't just store into it
112 if [ $? != 0 ] ; then
113    rstat=$?
114 fi
115
116 #
117 # Delete .c files because we will only restored the txt files
118 #
119 rm -f ${cwd}/tmp/build/*.c
120 check_restore_tmp_build_diff
121
122 end_test