]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/migration-job-purge-test
518b63c961cf17d328340d3bab6055e46fb75528
[bacula/bacula] / regress / tests / migration-job-purge-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory then migrate it
4 #   to another device, and see if PurgeMigrationJob works as expected.
5 #
6 # This script uses the virtual disk autochanger
7 #
8 TestName="migration-job-purge-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
20 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "PurgeMigrationJob", "yes", "Job", "migrate-job")'
21
22 start_test
23
24 #
25 # Note, we first backup into Pool Default, 
26 #          then Migrate into Pool Full. 
27 #              Pool Default uses Storage=File
28 #              Pool Full    uses Storage=DiskChanger
29
30 # Write out bconsole commands
31 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
32 @$out /dev/null
33 messages
34 @$out ${cwd}/tmp/log1.out
35 setdebug level=000 storage=File
36 label storage=File volume=FileVolume001 Pool=Default
37 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
38 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
39 @# run two jobs (both will be migrated)
40 run job=$JobName yes
41 run job=$JobName yes
42 wait
43 list jobs
44 list volumes
45 @#setdebug level=100 dir
46 @# should migrate two jobs
47 @#setdebug level=51 storage=DiskChanger
48 run job=migrate-job yes
49 wait
50 messages
51 @# purge volume=FileVolume001
52 list jobs 
53 list volumes
54 list joblog jobid=6
55 wait
56 @#
57 @# Now do another backup, but level Incremental
58 @#
59 run job=$JobName level=Incremental yes
60 wait
61 messages
62 @#
63 @# This final job that runs should be Incremental and
64 @# not upgraded to full.
65 list jobs
66 @# 
67 @# now do a restore
68 @#
69 @$out ${cwd}/tmp/log2.out
70 list volumes 
71 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
72 unmark *
73 mark *
74 done
75 yes
76 list volumes
77 wait
78 messages
79 @$out ${cwd}/tmp/log3.out
80 list jobid=1
81 list jobid=2
82 quit
83 END_OF_DATA
84
85 run_bacula
86 check_for_zombie_jobs storage=File
87 stop_bacula
88
89 check_two_logs
90 check_restore_diff
91
92 # Shouldn't find MigrationJobSave jobid 1 or 2 in log3.out
93 grep MigrationJobSave $tmp/log3.out
94 if [ $? -eq 0 ]; then
95     print_debug "ERROR: found purged jobids in $tmp/log3.out"
96     estat=1
97 fi
98
99 end_test