]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/prune-copy-test
Make verify job log same as other logs -- fixes bug #2328
[bacula/bacula] / regress / tests / prune-copy-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 # Not yet working
8 #
9 # Run a simple backup of the Bacula build directory then copy it
10 #   to another device.
11 ##
12 TestName="prune-copy-test"
13 JobName=CopyJobSave
14 . scripts/functions
15
16
17 scripts/cleanup
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
23
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 change_jobname NightlySave $JobName
29 start_test
30
31 #
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
36
37 # Write out bconsole commands
38 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
39 @output /dev/null
40 messages
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
47 wait
48 run job=$JobName level=Full yes
49 wait
50 list jobs
51 list volumes
52 @#setdebug level=100 dir
53 @# should copy two jobs
54 @#setdebug level=51 storage=DiskChanger
55 @sleep 2
56 run job=copy-job yes
57 wait
58 messages
59 @#purge volume=FileVolume001
60 list jobs 
61 list volumes
62 wait
63 messages
64 @#
65 @# Now do another backup, but level Incremental
66 @#
67 @sleep 2
68 run job=$JobName level=Incremental yes
69 wait
70 messages
71 @#
72 @# This final job that runs should be Incremental and
73 @# not upgraded to full.
74 @sleep 2
75 @exec "touch $cwd/build/po/fr.po"
76 run job=$JobName level=Incremental yes
77 wait
78 messages
79 @$out ${cwd}/tmp/log10.out
80 @sleep 1
81 setdebug level=1 director
82 list jobs
83 sql
84 SELECT JobId, Name, JobTDate, StartTime, Type, Level, JobFiles, JobStatus
85 FROM Job ORDER BY StartTime;
86
87 prune jobs yes
88 list jobs
89 @################################################################ 
90 @# now do a restore
91 @#
92 @$out ${cwd}/tmp/log2.out
93 list volumes 
94 restore where=${cwd}/tmp/bacula-restores select
95 unmark *
96 mark *
97 done
98 yes
99 list volumes
100 wait
101 messages
102 quit
103 END_OF_DATA
104
105 run_bacula
106 check_for_zombie_jobs storage=File
107 stop_bacula
108
109 check_two_logs
110 check_restore_diff
111
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.
117
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 + $?))
123
124 end_test