]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/prune-migration-test
regress: enhance btape-test to detect NOT correct message
[bacula/bacula] / regress / tests / prune-migration-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 then migrate it
9 #   to another device, then see how prune code handle that
10 #
11 # This script uses the virtual disk autochanger
12 #
13 TestName="prune-migration-test"
14 JobName=MigrationJobSave
15 . scripts/functions
16
17
18 scripts/cleanup
19 scripts/copy-migration-confs
20 scripts/prepare-disk-changer
21 echo "${cwd}/build" >${cwd}/tmp/file-list
22
23 change_jobname NightlySave $JobName
24 dircfg=$conf/bacula-dir.conf
25 $bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
26 $bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
27
28 start_test
29
30 #
31 # Note, we first backup into Pool Default, 
32 #          then Migrate into Pool Full. 
33 #              Pool Default uses Storage=File
34 #              Pool Full    uses Storage=DiskChanger
35
36 # Write out bconsole commands
37 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
38 @output /dev/null
39 messages
40 @$out ${cwd}/tmp/log1.out
41 setdebug level=100 storage=File
42 label storage=File volume=FileVolume001 Pool=Default
43 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
44 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
45 @# run two jobs (both will be migrated)
46 run job=$JobName yes
47 @sleep 4
48 wait
49 @sleep 3
50 run job=$JobName yes
51 wait
52 @sleep 5
53 list jobs
54 @# should migrate two jobs
55 setdebug level=1 storage=File
56 run job=migrate-job yes
57 @sleep 3
58 run job=migrate-job yes
59 wait
60 messages
61 list jobs 
62 wait
63 @sleep 3
64 @#
65 @# Now do another backup, but level Incremental
66 @#
67 run job=$JobName level=Incremental yes
68 wait
69 messages
70 @sleep 3
71 @################################################################
72 @$out $cwd/tmp/log10.out
73 setdebug level=1 director
74 sql
75 SELECT JobId, JobTDate, StartTime, EndTime, Type FROM Job;
76
77 list jobs
78 prune jobs yes
79 list jobs
80 sql
81 SELECT JobId, JobTDate, StartTime, EndTime, Type FROM Job;
82
83 @################################################################ 
84 @# now do a restore
85 @#
86 @$out ${cwd}/tmp/log2.out
87 list volumes 
88 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
89 unmark *
90 mark *
91 done
92 yes
93 list volumes
94 wait
95 messages
96 quit
97 END_OF_DATA
98
99 run_bacula
100 check_for_zombie_jobs storage=File
101 stop_bacula
102
103 check_two_logs
104 check_restore_diff
105
106 # Now we will verify that the pruning code is working as expected.  Each time,
107 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
108 # in argument are present in the first 'list jobs', the 'prune' command deletes
109 # them (same number), and checks that the last 'list jobs' doesn't contain them
110 # anymore. See scripts/functions.pm for details.
111
112 # M M g g F F I0 -> F
113 # Note, for some strange reason, we end either with JobId=5 or
114 #  with JobId=8.  Why it changes, I do not know, so we permit
115 #  both of them below (absence of 5 and 8 in the list).
116 $bperl -e "check_prune_list('$tmp/log10.out',1,2,3,4,7,9)"
117 estat=$(($estat + $?))
118
119 end_test