3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a basejob backup of the Bacula build directory
12 TestName="base-job-test"
18 echo 's/backup_advance/base_backup/' > $tmp/s
19 echo 's/Name = backup/Name = backup; Base = base_backup, backup/' >> $tmp/s
20 sed -f $tmp/s $rscripts/bacula-dir.conf.accurate > $conf/bacula-dir.conf
23 sed s/all,/all,saved,/ $conf/bacula-fd.conf > tmp/1
24 cp tmp/1 $conf/bacula-fd.conf
26 change_jobname BackupClient1 $JobName
29 echo "##############################################" >> ${cwd}/tmp/log1.out
30 echo "$*" >> ${cwd}/tmp/log1.out
31 echo "##############################################" >> ${cwd}/tmp/log2.out
32 echo "$*" >> ${cwd}/tmp/log2.out
36 rm -rf ${cwd}/build/accurate.new
37 rm -rf ${cwd}/build/accurate
41 mkdir ${cwd}/build/accurate
42 mkdir ${cwd}/build/accurate/dirtest
43 echo "test test" > ${cwd}/build/accurate/dirtest/hello
44 echo "test test" > ${cwd}/build/accurate/xxx
45 echo "test test" > ${cwd}/build/accurate/yyy
46 echo "test test" > ${cwd}/build/accurate/zzz
47 echo "test test" > ${cwd}/build/accurate/zzzzzz
48 echo "test test" > ${cwd}/build/accurate/xxxxxx
49 echo "test test" > ${cwd}/build/accurate/yyyyyy
50 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
51 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
52 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
53 echo ${cwd}/build > ${cwd}/tmp/file-list
57 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
60 label volume=TestVolume001 storage=File pool=Default
66 ################################################################
67 p Now do a backup using base backup
68 ################################################################
70 echo ${cwd}/bin >> ${cwd}/tmp/file-list
72 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
73 @$out ${cwd}/tmp/log1.out
74 run job=base_backup level=base yes
77 update volume=TestVolume001 volstatus=Used
82 echo ${cwd}/build > ${cwd}/tmp/file-list
84 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
85 @$out ${cwd}/tmp/log4.out
86 label volume=TestVolume002 storage=File pool=Default
87 run job=backup level=full yes
93 @$out ${cwd}/tmp/log2.out
94 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
102 check_for_zombie_jobs storage=File
107 rm -rf ${cwd}/tmp/bacula-restores
109 grep -e 'FD Bytes Written: *0' ${cwd}/tmp/log4.out > /dev/null
110 if [ $? -ne 0 ]; then
111 print_debug "ERROR: The first full job should have 0 byte in log4.out"
115 grep -e 'Using BaseJobId(s): 1$' ${cwd}/tmp/log4.out > /dev/null
116 if [ $? -ne 0 ]; then
117 print_debug "ERROR: The first full job should use only jobid=1 as basejob"
121 ################################################################
122 p Now do a backup after making few changes
123 ################################################################
124 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
125 @$out ${cwd}/tmp/log1.out
126 update volume=TestVolume002 volstatus=Used
127 label volume=TestVolume003 storage=File pool=Default
128 run job=backup level=incremental yes
135 @$out ${cwd}/tmp/log2.out
136 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
142 rm ${cwd}/build/accurate/yyyyyy # delete a file
143 rm -rf ${cwd}/build/accurate/dirtest
147 check_for_zombie_jobs storage=File
151 check_files_written ${cwd}/tmp/log1.out 4
153 rm -rf ${cwd}/tmp/bacula-restores
155 ################################################################
157 ################################################################
158 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
159 @$out ${cwd}/tmp/log3.out
161 SELECT count(*) FROM BaseFiles;
163 purge volume=TestVolume002
166 SELECT count(*) FROM BaseFiles;
172 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
173 if [ $? -ne 0 ]; then
174 print_debug "ERROR: Can't purge the base job"
179 ################################################################
181 ################################################################
183 touch ${cwd}/build/po/fr.po
185 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
186 run level=full job=backup yes
189 @out ${cwd}/tmp/log5.out
190 list basefiles jobid=6
191 @out ${cwd}/tmp/log6.out
198 grep "po/fr.po^" ${cwd}/tmp/log5.out > /dev/null
199 if [ $? -eq 0 ]; then
200 print_debug "ERROR: Should not display fr.po as basefile"
204 export bstat dstat estat