]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/virtual-changer-test
baculum: Add strip_prefix, add_prefix, add_suffix and regex_where restore options...
[bacula/bacula] / regress / tests / virtual-changer-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run a simple backup of the Bacula build directory. Create three
9 #   tapes, each in a different pool, then run two jobs both of which
10 #   want the disk that is not loaded.  Note, they both have     
11 #   prefers non-mounted tapes.  This should expose bug #801
12 #
13 #  This test the SD Virtual autochanger feature.  It is a disk based
14 #    "autochanger", but does not use any changer script.
15 #
16 #  Note, because we limit each drive to a maximum of 3 jobs,
17 #  the first three start on Drive-0, and the second three start
18 #  on drive-1 (Prefer Mounted Volumes = no).  Thus since there
19 #  is only one Volume (TestVolume001) that is valid, three jobs
20 #  block and ask the user to create a new volume.  However, at some
21 #  point, the first three jobs finish and free up TestVolum001, and
22 #  Since we set a poll interval of 15 seconds, after a short wait
23 #  TestVolume001 will be mounted on drive-1 and the job will
24 #  complete.  This tests a good number of things.
25 #
26 TestName="virtual-changer-test"
27 JobName="virtualchangertest"
28 . scripts/functions
29
30 scripts/cleanup
31 scripts/copy-2disk-drive-confs
32 scripts/prepare-disk-changer
33
34 CLIENT=2drive2disk
35
36 echo "${cwd}/build" >${cwd}/tmp/file-list
37 #change_jobname Virtual $JobName
38 start_test
39
40 # Turn off Prefer Mounted Volumes so we use 2 drives
41 outf="${cwd}/tmp/sed_tmp"
42 echo "s%# Prefer Mounted Volumes%  Prefer Mounted Volumes%g" >${outf}
43 cp ${cwd}/bin/bacula-dir.conf ${cwd}/tmp/1
44 # Comment the next line out to write everything to one drive
45 #  otherwise, it writes the two jobs to different drives
46 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
47
48 # Write out bconsole commands
49 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
50 @output /dev/null
51 messages
52 @$out ${cwd}/tmp/log1.out
53 setdebug level=50 storage=Virtual
54 @#setdebug level=200 client=$CLIENT 
55 label storage=Virtual volume=TestVolume001 slot=1 Pool=Default drive=0
56 label storage=Virtual volume=TestVolume002 slot=2 Pool=Full    drive=0
57 label storage=Virtual volume=TestVolume003 slot=3 Pool=Inc     drive=1
58 status storage=Virtual
59 run job=Virtual level=Full Pool=Default yes
60 run job=Virtual level=Full Pool=Default yes
61 run job=Virtual level=Full Pool=Default yes
62 run job=Virtual level=Full Pool=Default yes
63 run job=Virtual level=Full Pool=Default yes
64 @sleep 10
65 status storage=Virtual
66 list volumes
67 wait
68 list volumes
69 list jobs
70 status storage=Virtual
71 messages
72 quit
73 END_OF_DATA
74
75 # exit
76
77 run_bacula
78 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
79 @output /dev/null
80 messages
81 @# 
82 @# now do a restore
83 @#
84 @$out ${cwd}/tmp/log2.out
85 restore where=${cwd}/tmp/bacula-restores select all storage=Virtual done
86 yes
87 wait
88 messages
89 quit
90 END_OF_DATA
91
92 run_bconsole
93
94 check_for_zombie_jobs storage=Virtual
95 stop_bacula
96
97 check_two_logs
98 check_restore_diff
99
100 end_test