3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
9 # Run a simple backup of the Bacula build directory then copy it
12 TestName="prune-copy-test"
18 scripts/copy-migration-confs
19 scripts/prepare-disk-changer
20 echo "${cwd}/build" >${cwd}/tmp/file-list
21 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
22 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
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')"
28 change_jobname NightlySave $JobName
32 # Note, we first backup into Pool Default,
33 # then Copy into Pool Full.
34 # Pool Default uses Storage=File
35 # Pool Full uses Storage=DiskChanger
37 # Write out bconsole commands
38 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
41 @$out ${cwd}/tmp/log1.out
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 copied)
46 run job=$JobName level=Full yes
48 run job=$JobName level=Full yes
52 @#setdebug level=100 dir
53 @# should copy two jobs
54 @#setdebug level=51 storage=DiskChanger
59 @#purge volume=FileVolume001
65 @# Now do another backup, but level Incremental
68 run job=$JobName level=Incremental yes
72 @# This final job that runs should be Incremental and
73 @# not upgraded to full.
75 @exec "touch $cwd/build/po/fr.po"
76 run job=$JobName level=Incremental yes
79 @$out ${cwd}/tmp/log10.out
81 setdebug level=1 director
84 SELECT JobId, Name, JobTDate, StartTime, Type, Level, JobFiles, JobStatus
85 FROM Job ORDER BY StartTime;
89 @################################################################
92 @$out ${cwd}/tmp/log2.out
94 restore where=${cwd}/tmp/bacula-restores select
106 check_for_zombie_jobs storage=File
112 # Now we will verify that the pruning code is working as expected. Each time,
113 # we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
114 # in argument are present in the first 'list jobs', the 'prune' command deletes
115 # them (same number), and checks that the last 'list jobs' doesn't contain them
116 # anymore. See scripts/functions.pm for details.
118 # Copy jobs are pruned like normal jobs after the Job Retention period
119 # the admin 'c'opy job should also be pruned
120 # F F c c C C I0 I -> F I
121 $bperl -e "check_prune_list('$tmp/log10.out',1,3,4,5,6,7)"
122 estat=$(($estat + $?))