3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a simple backup of the Bacula build directory then migrate it
9 # to another device, then see how prune code handle that
11 # This script uses the virtual disk autochanger
13 TestName="prune-migration-test"
14 JobName=MigrationJobSave
19 scripts/copy-migration-confs
20 scripts/prepare-disk-changer
21 echo "${cwd}/build" >${cwd}/tmp/file-list
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')"
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
36 # Write out bconsole commands
37 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
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)
54 @# should migrate two jobs
55 setdebug level=1 storage=File
56 run job=migrate-job yes
58 run job=migrate-job yes
65 @# Now do another backup, but level Incremental
67 run job=$JobName level=Incremental yes
71 @################################################################
72 @$out $cwd/tmp/log10.out
73 setdebug level=1 director
75 SELECT JobId, JobTDate, StartTime, EndTime, Type FROM Job;
81 SELECT JobId, JobTDate, StartTime, EndTime, Type FROM Job;
83 @################################################################
86 @$out ${cwd}/tmp/log2.out
88 restore where=${cwd}/tmp/bacula-restores select storage=DiskChanger
100 check_for_zombie_jobs storage=File
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.
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 + $?))