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