]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/copy-uncopied-test
Backport from Bacula Enterprise
[bacula/bacula] / regress / tests / copy-uncopied-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6
7 #
8 # Run a backup of the Bacula build directory on two Volumes
9 #   then copy it to another device.             
10 #
11 # This script uses the virtual disk autochanger and migration scripts
12 #
13 TestName="copy-uncopied-test"
14 JobName=MigVolBackup
15 . scripts/functions
16
17
18 scripts/cleanup
19 scripts/copy-migration-confs
20 scripts/prepare-disk-changer
21 echo "${cwd}/build" >${cwd}/tmp/file-list
22 #cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
23 #sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
24
25 change_jobname NightlySave $JobName
26 sed 's/migrate/copy/g' ${cwd}/bin/bacula-dir.conf > ${cwd}/tmp/1
27 sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bacula-dir.conf
28 rm -f ${cwd}/build/po/test.po >/dev/null
29
30 touch ${cwd}/tmp/log2.out
31
32 $bperl -e 'add_attribute("$conf/bacula-dir.conf", "Allow Duplicate Jobs", "no", "Job", "MigVolBackup")'
33
34 start_test
35
36 #
37 # Note, we first backup into Pool Default, 
38 #          then Copy into Pool Full. 
39 #              Pool Default uses Storage=File
40 #              Pool Full    uses Storage=DiskChanger
41
42 # Write out bconsole commands
43 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
44 @output /dev/null
45 messages
46 @$out ${cwd}/tmp/log1.out
47 label storage=File volume=FileVolume001 Pool=Default
48 label storage=File volume=FileVolume002 Pool=Scratch
49 label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0
50 label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0
51 @# 
52 run job=$JobName level=Full yes
53 wait
54 run job=$JobName level=Full yes
55 wait
56 update volume=FileVolume001 VolStatus=Used
57 run job=$JobName level=Full yes
58 wait
59 messages
60 @$out ${cwd}/tmp/log11.out
61 @############################################################
62 @# should copy job 1,2,3
63 @# Expect: 3 copies (1,2,3)
64 @############################################################
65 setdebug level=200 dir
66 run job=copy-uncopied yes
67 @sleep 5 
68 wait
69 messages
70 list jobs
71 list volumes
72 list copies
73 @$out ${cwd}/tmp/log12.out
74 @############################################################
75 @# should not copy jobs
76 @# Expect: 3 copies (1,2,3)
77 @############################################################
78 run job=copy-uncopied yes
79 wait
80 messages
81 list copies
82 @$out ${cwd}/tmp/log13.out
83 @############################################################
84 @# should not have a copy of the copy
85 @# Expect: 2 copies (2,3)
86 @############################################################
87 delete jobid=1
88 run job=copy-uncopied yes
89 wait
90 messages
91 list copies
92 @$out ${cwd}/tmp/log14.out
93 @############################################################
94 @# should copy jobid=2
95 @# Expect: 2 copies (2,3)
96 @############################################################
97 delete jobid=8
98 run job=copy-uncopied yes
99 wait
100 messages
101 list copies
102 END_OF_DATA
103
104 run_bacula
105 check_for_zombie_jobs storage=File
106 stop_bacula
107
108 bstat=0
109 rstat=0
110 dstat=0
111 zstat=0
112
113 perl -Mscripts::functions -e 'check_multiple_copies(3)' tmp/log11.out
114 bstat=`expr $bstat + $?`
115
116 perl -Mscripts::functions -e 'check_multiple_copies(3)' tmp/log12.out
117 bstat=`expr $bstat + $?`
118
119 perl -Mscripts::functions -e 'check_multiple_copies(2)' tmp/log13.out
120 bstat=`expr $bstat + $?`
121
122 perl -Mscripts::functions -e 'check_multiple_copies(2)' tmp/log14.out
123 bstat=`expr $bstat + $?`
124
125 check_two_logs
126 end_test